JavaScriptを使用してC++経由でExcelスプレッドシートファイルの設定を管理します。
Contents
[
Hide
]
ワークブック設定の概要
Excelファイルの操作にはさまざまな設定が関わっており、これらをC++経由のAspose.Cells for JavaScriptを使用してプログラム的に操作できます。本書は、これらの設定を効果的に管理する方法を示しています。
可能な使用シナリオ
次のシナリオは、ワークブック設定を管理する必要がある場合を示しています:
- 表示オプションの調整
- 計算モードの設定
- ページ設定パラメータの構成
C++を使用したAspose.Cells for JavaScriptでのワークブック設定の管理
この例では、計算オプションや表示設定など、ワークブックの設定を管理する方法を示します。
- 新しいワークブックを作成するか、既存のものをロードします。
- 要件に応じてワークブック設定を変更します。
- 変更を保存してワークブックを保持します。
例のコード
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Workbook Settings Example</h1>
<input type="file" id="fileInput" accept=".xls,.xlsx,.csv" />
<button id="runExample">Run Example</button>
<a id="downloadLink" style="display: none;">Download Result</a>
<div id="result"></div>
</body>
<script src="aspose.cells.js.min.js"></script>
<script type="text/javascript">
const { Workbook, SaveFormat } = AsposeCells;
AsposeCells.onReady({
license: "/lic/aspose.cells.enc",
fontPath: "/fonts/",
fontList: [
"arial.ttf",
"NotoSansSC-Regular.ttf"
]
}).then(() => {
console.log("Aspose.Cells initialized");
});
document.getElementById('runExample').addEventListener('click', async () => {
// Create a new workbook
const workbook = new Workbook();
// Access the settings of the workbook
const settings = workbook.settings;
settings.calculationMode = 1; // Manual calculation
// Display options
settings.showGridLines = false; // Disable gridlines
// Save the workbook
const outputData = workbook.save(SaveFormat.Xlsx);
const blob = new Blob([outputData]);
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'WorkbookSettingsExample.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Excel File';
document.getElementById('result').innerHTML = '<p style="color: green;">Workbook created successfully! Click the download link to get the file.</p>';
});
</script>
</html>
主要なワークブック設定のプロパティとメソッド
C++を使用したAspose.Cells for JavaScriptは、ワークブック設定を調整するための多くのプロパティとメソッドを提供します:
- Workbook.settings: ワークブックの設定にアクセスします。
- Settings.calculationMode: ワークブックの計算モードを設定します。
- Settings.showGridLines: グリッド線の表示を有効または無効にします。
結論
C++経由のAspose.Cells for JavaScriptでワークブック設定を管理するのは簡単であり、Excelファイルの動作をカスタマイズする多くのオプションを提供します。利用可能な設定を活用することで、あなたの特定の要件に合わせてワークブックを調整できます。