如何控制工作簿视图
Contents
[
Hide
]
可能的使用场景
当您需要调整Excel页面的显示时,您需要知道如何控制每个模块,例如水平和垂直滚动条,是否隐藏打开的Excel文件等。Aspose.Cells提供了此功能。
- WorkbookSettings.IsHScrollBarVisible
- WorkbookSettings.IsVScrollBarVisible
- WorkbookSettings.IsHidden
- WorkbookSettings.IsMinimized
- WorkbookSettings.WindowHeight
- WorkbookSettings.WindowWidth
- WorkbookSettings.WindowLeft
- WorkbookSettings.WindowTop
使用Aspose.Cells for .NET了解如何控制工作簿视图。
此示例演示如何:
- 创建一个工作簿。
- 在第一个工作表中的单元格中添加数据。
- 隐藏工作簿视图的水平和垂直滚动条。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Instantiating an Workbook object | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the newly added worksheet | |
Worksheet ws = workbook.Worksheets[0]; | |
Aspose.Cells.Cells cells = ws.Cells; | |
//Setting the value to the cells | |
Aspose.Cells.Cell cell = cells["A1"]; | |
cell.PutValue("Fruit"); | |
cell = cells["B1"]; | |
cell.PutValue("Count"); | |
cell = cells["C1"]; | |
cell.PutValue("Price"); | |
cell = cells["A2"]; | |
cell.PutValue("Apple"); | |
cell = cells["A3"]; | |
cell.PutValue("Mango"); | |
cell = cells["A4"]; | |
cell.PutValue("Blackberry"); | |
cell = cells["A5"]; | |
cell.PutValue("Cherry"); | |
cell = cells["B2"]; | |
cell.PutValue(5); | |
cell = cells["B3"]; | |
cell.PutValue(3); | |
cell = cells["B4"]; | |
cell.PutValue(6); | |
cell = cells["B5"]; | |
cell.PutValue(4); | |
cell = cells["C2"]; | |
cell.PutValue(5); | |
cell = cells["C3"]; | |
cell.PutValue(20); | |
cell = cells["C4"]; | |
cell.PutValue(30); | |
cell = cells["C5"]; | |
cell.PutValue(60); | |
cell = cells["E10"]; | |
Style temp = workbook.CreateStyle(); | |
temp.Font.Color = Color.Red; | |
cell.SetStyle(temp); | |
//Hide horizontal and vertical scrollbars | |
workbook.Settings.IsHScrollBarVisible = false; | |
workbook.Settings.IsVScrollBarVisible = false; | |
workbook.Save("out.xlsx"); |
结果文件预览: