冻结窗格中的OpenXML SDK 2.0 Excel文档 [英] Freeze Panes in OpenXml SDK 2.0 for Excel document

查看:1106
本文介绍了冻结窗格中的OpenXML SDK 2.0 Excel文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的OpenXML生成一个Excel工作簿,并已在如下例子http://msdn.microsoft.com/en-us/library/cc850837.aspx

I'm generating an Excel workbook using OpenXml and have been following the examples at http://msdn.microsoft.com/en-us/library/cc850837.aspx

这将是非常有用的,如果我能冻顶窗格,但我不能找到一个方法来做到这一点。我意识到,如果我用我能做到这一点 http://closedxml.codeplex.com/ 但现在我倒要坚持OpenXML的SDK

It would be really useful if I could freeze the top panes, but I can't find a way to do this. I realise that I can do this if I use http://closedxml.codeplex.com/ but for now I'd like to stick to the OpenXml SDK

任何想法?

推荐答案

我试图解决同样的问题,最终打开的Open XML SDK 2.0生产力工具,并使用比较文件... 功能比较两个电子表格,其中一个,冻结的窗格,一个没有

I was trying to solve the same problem and ended up opening the Open XML SDK 2.0 Productivity Tool and using the Compare Files... feature to compare two spreadsheets, one with frozen panes and one without.

当我这样做,我被领到看起来基本上是这样的代码:

When I did that, I was led to code that looked basically like this:

WorkbookPart wbp = doc.WorkbookPart;
WorksheetPart wsp = wbp.WorksheetParts.First();

SheetViews sheetviews = wsp.Worksheet.GetFirstChild<SheetViews>();
SheetView sv = sheetviews.GetFirstChild<SheetView>();
Selection selection = sv.GetFirstChild<Selection>();
Pane pane = new Pane(){ VerticalSplit = 1D, TopLeftCell = "A2", ActivePane = PaneValues.BottomLeft, State = PaneStateValues.Frozen };
sv.InsertBefore(pane,selection);
selection.Pane = PaneValues.BottomLeft;



我说这我的程序,它似乎做的伎俩。

I added this to my program and it seemed to do the trick.

这篇关于冻结窗格中的OpenXML SDK 2.0 Excel文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆