JavaScriptを使用してワークブックのAutoRecoverプロパティを設定する方法(C++経由)
Contents
[
Hide
]
Aspose.Cellsを使用して、ワークブックの自動回復プロパティを設定できます。このプロパティのデフォルト値はtrueです。これをfalseに設定すると、Microsoft ExcelはそのExcelファイルの自動回復(自動保存)を無効にします。
Aspose.Cellsは、このオプションを有効または無効にするためのWorkbook.autoRecoverプロパティを提供しています。
以下のコードは、ワークブックのWorkbook.autoRecoverプロパティの使用方法を説明します。最初にこのプロパティのデフォルト値(true)を読み取り、その後falseに設定してワークブックを保存します。次に再度ワークブックを読み取り、その時点でのこのプロパティの値(false)を確認します。
ワークブックのAutoRecoverプロパティを設定するJavaScriptコード
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example - AutoRecover</title>
</head>
<body>
<h1>AutoRecover Property 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, Worksheet, Cell, Utils } = 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 () => {
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = '';
// Create workbook object
const workbook = new Workbook();
// Read AutoRecover property
const autoRecoverBefore = workbook.settings.autoRecover;
resultDiv.innerHTML += `<p>AutoRecover before: ${autoRecoverBefore}</p>`;
// Set AutoRecover property to false
workbook.settings.autoRecover = false;
// 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 = 'output_out.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download output_out.xlsx';
// Read the saved workbook again from the saved data
const workbook2 = new Workbook(new Uint8Array(outputData));
// Read AutoRecover property
const autoRecoverAfter = workbook2.settings.autoRecover;
resultDiv.innerHTML += `<p>AutoRecover after reload: ${autoRecoverAfter}</p>`;
});
</script>
</html>
出力
AutoRecover: True
AutoRecover: False