JavaScriptを介してC++でWorkbook内のVBAプロジェクトに署名されているか確認する
Contents
[
Hide
]
Microsoft Excelでは、**ツール > デジタル署名…**メニューコマンドを使用してVBAプロジェクトが署名されているかどうかを確認できます。同様に、Aspose.CellsのWorkbook.vbaProjectプロパティを使用してプログラムで確認することも可能です。
JavaScriptでWorkbook内のVBAプロジェクトに署名されているか確認する
以下のコードは、ワークブックをロードし、そのVBAプロジェクトが署名されているかどうかを Workbook.vbaProjectプロパティを使用して判定します。署名されている場合は true を返し、そうでなければfalseを返します。
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Aspose.Cells VBA Signed Check</h1>
<input type="file" id="fileInput" accept=".xls,.xlsx,.xlsm" />
<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, 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 fileInput = document.getElementById('fileInput');
if (!fileInput.files.length) {
document.getElementById('result').innerHTML = '<p style="color: red;">Please select an Excel file.</p>';
return;
}
const file = fileInput.files[0];
const arrayBuffer = await file.arrayBuffer();
// Instantiating a Workbook object from the uploaded file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Accessing the VBA project and checking if it's signed
const isSigned = workbook.vbaProject.isSigned;
console.log("VBA Project is Signed: " + isSigned);
document.getElementById('result').innerHTML = `<p>VBA Project is Signed: ${isSigned}</p>`;
});
</script>
</html>