تحميل وإدارة ملفات إكسل، OpenOffice، Json، Csv و Html
Contents
[
Hide
]
مع Aspose.Cells، من السهل إنشاء، فتح، وإدارة ملفات إكسل، على سبيل المثال، لاسترجاع البيانات، أو استخدام قالب مصمم لتسريع عملية التطوير.
إنشاء مصنف جديد
يُظهر المثال التالي إنشاء دفتر عمل جديد من الصفر.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Aspose.Cells Example - Create Workbook and Set Cell Value</h1>
<input type="file" id="fileInput" accept=".xls,.xlsx,.csv" />
<button id="runExample">Create 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.lic",
fontPath: "/fonts/",
fontList: [
"arial.ttf",
"NotoSansSC-Regular.ttf"
]
}).then(() => {
console.log("Aspose.Cells initialized");
});
document.getElementById('runExample').addEventListener('click', async () => {
// Instantiate a Workbook object (new blank workbook)
const wb = new Workbook();
// Access the first worksheet in the workbook
const sheet = wb.worksheets.get(0);
// Access the "A1" cell in the sheet
const cell = sheet.cells.get("A1");
// Input the "Hello World!" text into the "A1" cell
cell.value = "Hello World!";
// Save the Excel file and prepare download link
const outputData = wb.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 Excel File';
document.getElementById('result').innerHTML = '<p style="color: green;">Workbook created and cell updated. Click the download link to get the modified file.</p>';
});
</script>
</html>
فتح وحفظ ملف
مع Aspose.Cells، من السهل فتح، حفظ، وإدارة ملفات إكسل.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Aspose.Cells 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 } = 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();
// Creating a Workbook object and opening an Excel file using its file stream
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Adding new sheet
const sheetIndex = workbook.worksheets.add("MySheet");
const sheet = workbook.worksheets.get(sheetIndex);
// Setting active sheet
workbook.worksheets.activeSheetIndex = 1;
// Setting values.
const cells = sheet.cells;
// Setting text
cells.get("A1").putValue("Hello!");
// Setting number
cells.get("A2").putValue(1000);
// Setting Date Time
const cell = cells.get("A3");
cell.putValue(new Date());
const style = cell.style;
style.number = 14;
cell.style = style;
// Setting formula
cells.get("A4").formula = "=SUM(A1:A3)";
// Saving the workbook and providing download link
const outputData = workbook.save(SaveFormat.Xlsx);
const blob = new Blob([outputData]);
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'dest.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Excel File';
document.getElementById('result').innerHTML = '<p style="color: green;">Operation completed successfully! Click the download link to get the modified file.</p>';
});
</script>
</html>
مواضيع متقدمة
- طرق مختلفة لفتح الملفات
- تصفية أسماء محددة أثناء تحميل المصنف
- تصفية الكائنات أثناء تحميل مصنف العمل أو ورقة العمل
- تصفية نوع البيانات أثناء تحميل مصنف العمل من ملف القالب
- الحصول على تحذيرات أثناء تحميل ملف إكسل
- تحميل ملف Excel المصدر دون الرسوم البيانية
- تحميل الأوراق العمل المحددة في كتيب عمل
- تحميل الدفتر بحجم ورقة الطابعة المحدد
- فتح ملفات Microsoft Excel مختلفة الإصدارات
- فتح الملفات بتنسيقات مختلفة
- تحسين استخدام الذاكرة أثناء العمل مع ملفات كبيرة تحتوي على مجموعات بيانات كبيرة
- قراءة جدول بيانات الأرقام المطور من قبل Apple Inc. باستخدام Aspose.Cells
- توقّف عن التحويل أو التحميل باستخدام InterruptMonitor عندما يستغرق وقتًا طويلاً
- استخدام واجهة برمجة التطبيقات LightCells
- تحويل CSV إلى JSON
- تحويل إكسل إلى JSON
- تحويل JSON إلى CSV
- تحويل JSON إلى إكسل
- تحويل إكسل إلى Html