簡體   English   中英

隱藏的單元格仍顯示在OfficeWriter Excel電子表格中

[英]Hidden Cells still showing in an OfficeWriter Excel Spreadsheet

當我的Office Writer Excel報表打開時,它會隨機取消隱藏某些隱藏的單元格和列。 我已經驗證不是導致列或單元格不被隱藏的數據。 有沒有人曾經經歷過這種情況,並且有一種方法可以確保打開excel文件時所有列或單元格都保持隱藏狀態?

我為SoftArtisans工作。 我們還沒有任何其他報告以編程方式隱藏的列在輸出文件中變得可見。 我們也無法重現您報告的行為。 查看代碼段,以及了解使用的是哪個版本的OfficeWriter以及使用哪個版本的Excel打開輸出文件,將很有幫助。

有兩種使用我們的API隱藏列的方法,兩種方法都使用ColumnProperties對象。 您可以將hidden屬性設置為true或將width屬性設置為零。 如果您願意,您可以兩者都做,盡管這不是必需的。

例如:

ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Create(ExcelApplication.FileFormat.Xlsx);
//or if opening an existing workbook
//Workbook wb = xla.Open(inputFilePath);
//Get a handle on the worksheet
Worksheet ws = wb.Worksheets[0];
//Write a value to a cell
ws.Cells[0, 9].Value = "Hidden Value";
//Get a handle on the column you want to hide
ColumnProperties colProps = ws.GetColumnProperties(9);
//set the column to hidden
colProps.Hidden = true;
//or set the column width to zero
colProps.Width = 0;
//Stream the output file to the response
xla.Save(wb, Page.Response, "HiddenColumnTest.xlsx", false);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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