[英]With OpenXML how do I get the StyleIndex of an existing style in an excel spreadsheet
I am editing an existing excel spreadsheet with an existing cell Style in it called " myFavouriteStyle ". 我正在编辑一个现有的excel电子表格,其中包含一个名为“ myFavouriteStyle ”的现有单元格样式。
Using OpenXML SDK V2 c# how do I find the StyleIndex of that style so I can apply it to new cell(s) I add to the spreadsheet. 使用OpenXML SDK V2 c#,如何找到该样式的StyleIndex ,以便可以将其应用于添加到电子表格中的新单元格。
Thanks. 谢谢。
If you can get a reference to a Cell with the "myFavouriteStyle" applied to it you could: 如果您可以获得对引用了应用了“ 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.