ワークブックビューの制御方法

可能な使用シナリオ

Excelページの表示を調整する必要がある場合、水平および垂直のスクロールバーのような各モジュールの制御方法、開いているExcelファイルの非表示化の有無などを知る必要があります。Aspose.Cellsはこの機能を提供します。Aspose.Cellsは、あなたの目標を達成するのに役立つ以下のプロパティやメソッドを提供します。

Aspose.Cells for .NETを使用してワークブックビューを制御する方法

この例では、次のことができます:

  1. ワークブックを作成する。
  2. 最初のワークシートのセルにデータを追加する。
  3. ワークブックビューの水平および垂直のスクロールバーを非表示にする。
//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");

結果ファイルのプレビュー: