Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编辑一个现有的 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; }