0

当我的 Office Writer Excel 报表打开时,它会随机取消隐藏一些隐藏的单元格和列。我已经验证不是数据导致列或单元格不被隐藏。以前有没有人经历过这种情况,有没有办法确保在打开 excel 文件时所有列或单元格都保持隐藏状态?

4

1 回答 1

0

我为 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);
于 2013-11-20T22:16:08.767 回答