当我的Office Writer Excel报表打开时,它会随机取消隐藏某些隐藏的单元格和列。我已经验证了不是数据导致列或单元格不被隐藏。以前有没有人经历过这种情况,有没有办法确保在打开excel文件时所有的列或单元格都保持隐藏状态?
发布于 2013-11-21 06:16:09
我为SoftArtisans工作。我们还没有收到任何以编程方式隐藏的列在输出文件中变得可见的报告。我们也无法复制您报告的行为。查看代码片段以及了解您正在使用哪个版本的OfficeWriter以及正在使用哪个版本的Excel打开输出文件会很有帮助。
有两种方法可以使用我们的API隐藏列,这两种方法都使用ColumnProperties对象。您可以将hidden property设置为true或将width property设置为零。如果你愿意,你可以同时做这两件事,尽管这不应该是必要的。
例如:
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);https://stackoverflow.com/questions/19643436
复制相似问题