![](/img/trans.png)
[英]How can I only get visible cells in an Excel spreadsheet using OpenXML?
[英]With OpenXML how do I get the StyleIndex of an existing style in an excel spreadsheet
我正在编辑一个现有的excel电子表格,其中包含一个名为“ myFavouriteStyle ”的现有单元格样式。
使用OpenXML SDK V2 c#,如何找到该样式的StyleIndex ,以便可以将其应用于添加到电子表格中的新单元格。
谢谢。
如果您可以获得对引用了应用了“ myFavouriteStyle”的单元格的引用,则可以:
public static int GetCellStyleIndex(Cell theCell)
{
int cellStyleIndex;
if (theCell.StyleIndex == null)
{
cellStyleIndex = 0;
}
else
{
cellStyleIndex = (int)theCell.StyleIndex.Value;
}
return cellStyleIndex;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.