Implementieren Sie das 1904 Datumsystem mit JavaScript über C++
Contents
[
Hide
]
Microsoft Excel unterstützt zwei Datumsysteme: das 1900-Datumsystem (das Standard-Datumsystem, das in Excel für Windows implementiert ist) und das 1904-Datumsystem. Das 1904-Datumsystem wird normalerweise verwendet, um die Kompatibilität mit Macintosh-Excel-Dateien herzustellen und ist das Standard-System, wenn Sie Excel für Macintosh verwenden. Sie können das 1904-Datumsystem für Excel-Dateien mithilfe von Aspose.Cells for JavaScript über C++ einstellen.
Um das 1904-Datensystem in Microsoft Excel zu implementieren (zum Beispiel in Microsoft Excel 2003):
- Wählen Sie im Extras-Menü die Option Optionen und wählen Sie den Tab Berechnung.
- Wählen Sie die Option 1904-Datensystem aus.
- Klicken Sie auf OK.
| Auswählen des 1904-Datensystems in Microsoft Excel |
|---|
![]() |
Sehen Sie sich den folgenden Beispielcode an, wie Sie dies mit Aspose.Cells-APIs erreichen können.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Aspose.Cells Example - Enable 1904 Date System</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 () => {
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 by opening the uploaded Excel file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Implement 1904 date system
workbook.settings.date1904 = true;
// Saving the modified Excel file
const outputData = workbook.save(SaveFormat.Xlsx);
const blob = new Blob([outputData]);
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'Mybook.out.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Modified Excel File';
document.getElementById('result').innerHTML = '<p style="color: green;">1904 date system enabled. Click the download link to get the modified file.</p>';
});
</script>
</html>
