簡體   English   中英

使用OpenXML如何在Excel電子表格中獲取現有樣式的StyleIndex

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM