我有一個文檔,我的asp.net頁面正在創建,我需要將某些列的文本對齊到中心。在openXML SDK中手動將列置於中間位置後,我打開了文檔,但反映的代碼無法達到所需的結果。設置文本在C#中使用OpenXML在Excel文檔中居中對齊
這是我如何設置這些列的定製寬度,我想加入到這個功能(方法,whatevs)的能力居中文字:
private static Column CreateColumnData(UInt32 StartColumnIndex, UInt32 EndColumnIndex, double ColumnWidth)
{
Column column;
column = new Column();
column.Min = StartColumnIndex;
column.Max = EndColumnIndex;
column.Width = ColumnWidth;
column.CustomWidth = true;
//the SDK says to add this next line to center the text but it doesn't work
column.Style = (UInt32Value)6U;
return column;
}
我打開另一但我認爲解決方案非常簡單,我似乎無法得到它。如果任何人都可以提供幫助,那會很棒。
注:請記住,我使用的OpenXML和不會使用的Microsoft.Office.Interop.Excel
顯然,這不是那麼簡單。我無法改變我的方法來合併文本對齊。我必須通過StyleSheets。這很長,所以我可能會刪除這個問題,除非有人想看到我的解決方案。 – broguyman 2012-03-20 16:39:30