共有ワークブックをAspose.Cells for JavaScriptをC++で作成する
Contents
[
Hide
]
可能な使用シナリオ
Microsoft Excelでは、次のスクリーンショットのようにワークブックを共有できます。ワークブックを共有すると、複数のユーザーがネットワーク上で編集可能になります。Aspose.Cells for JavaScriptをC++を使うと、WorkbookSettings.sharedプロパティで共有ワークブックを作成できます。

Aspose.Cellsで共有ブックを作成する
以下のサンプルコードは、WorkbookSettings.sharedプロパティをtrueに設定して共有ワークブックを作成します。Microsoft Excelで出力Excelファイルを開くと、「共有」ステータスとともに出力済みのワークブック名が表示されます。

サンプルコード
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Create Shared Workbook Example</h1>
<input type="file" id="fileInput" accept=".xls,.xlsx,.csv" />
<button id="createShared" disabled>Create Shared Workbook</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('createShared').disabled = false;
});
document.getElementById('createShared').addEventListener('click', async () => {
const wb = new Workbook();
// Share the Workbook (converted getter/setter to property)
wb.settings.shared = true;
// Save the Shared Workbook
const outputData = wb.save(SaveFormat.Xlsx);
const blob = new Blob([outputData]);
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'outputSharedWorkbook.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Shared Workbook';
document.getElementById('result').innerHTML = '<p style="color: green;">Shared workbook created successfully! Click the download link to save the file.</p>';
});
</script>
</html>