[英]Set Row height in Excel through OpenXML
我有生成 Excel 工作表的代碼,我想在那里設置行高。
代碼如下:
Columns lstColumns = sheet1.Worksheet.GetFirstChild<Columns>();
bool needToInsertColumns = false;
if (lstColumns == null)
{
lstColumns = new Columns();
needToInsertColumns = true;
}
lstColumns.Append(
new Column() { Min = 1, Max = 1, Width = 120, CustomWidth = true }
);
if (needToInsertColumns)
{
sheet1.Worksheet.InsertAt(lstColumns, 0);
}
// For rows.
Row row;
row = new Row() { RowIndex = 1 };
row.Height = 100;
sheetData.Append(row);
通過以下代碼,我可以設置寬度但不能設置高度。
請執行下列操作:
Row row;
row = new Row() { RowIndex = 1 };
row.Height = 10.0;
row.CustomHeight = true;
或更好:
var row = new Row { Height = 10.0, CustomHeight = true, RowIndex = 1 };
CustomHeight 屬性在這里很重要。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.