HTML JavaScript ile C++ kullanımı
Excel Çalışma Kitabını HTML’ye Dönüştürme
Aspose.Cells API, elektronik tabloyu HTML formatına aktarmayı destekler. Bu amaçla, Aspose.Cells HtmlSaveOptions sınıfını kullanarak çıktı HTML’sinin çeşitli yönlerini kontrol etme esnekliği sağlar.
Aşağıdaki kod örneği, JavaScript ve C++ kullanarak bir çalışma kitabını HTML dosyası olarak kaydetmeyi gösterir:
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Aspose.Cells - Convert Excel to HTML</h1>
<input type="file" id="fileInput" accept=".xls,.xlsx,.csv" />
<button id="runExample">Convert to HTML</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 from the uploaded file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Saving the workbook to HTML format
const outputData = workbook.save(SaveFormat.Html);
const blob = new Blob([outputData], { type: 'text/html' });
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'out.html';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download HTML File';
document.getElementById('result').innerHTML = '<p style="color: green;">Conversion completed! Click the download link to get the HTML file.</p>';
});
</script>
</html>
Excel Çalışma Kitabını MHTML Dosyalarına Dönüştürme
MHTML, normal HTML’yi dış kaynaklar (örneğin, içerik bağlanan resimler, animasyonlar, sesler vb.) ile birleştirir ve tek bir dosyada tutar. .mht dosya uzantısına sahip e-postalar için kullanılır. Aspose.Cells, MHTML dosyalarını okuma ve yazmayı destekler.
Aşağıdaki kod örneği, JavaScript ve C++ kullanarak çalışma kitabını MHTML dosyası olarak kaydetmeyi gösterir:
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example - Save as MHT</title>
</head>
<body>
<h1>Save Excel as MHT 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 } = 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');
const resultDiv = document.getElementById('result');
if (!fileInput.files.length) {
resultDiv.innerHTML = '<p style="color: red;">Please select an Excel file.</p>';
return;
}
const file = fileInput.files[0];
const arrayBuffer = await file.arrayBuffer();
// Load your source workbook from the uploaded file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Save file to MHT format
const outputData = workbook.save(SaveFormat.MHtml);
const blob = new Blob([outputData], { type: 'application/octet-stream' });
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'out.mht';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download MHT File';
resultDiv.innerHTML = '<p style="color: green;">File converted to MHT successfully! Click the download link to get the result.</p>';
});
</script>
</html>
Gelişmiş Konular
-
HTML’den İçe Aktarırken Büyük Sayıların Üstel Görünümünü Engelle
-
HTML’ye kaydederken Downlevel Açıklanan Yorumları Devre Dışı Bırak
-
Çerçeve Betiklerini ve Belge Özelliklerini Dışa Aktarmayı Devre Dışı Bırak
-
Excel’den HTML’ye - Daha İyi Düzen için PresentationPreference Seçeneğini Kullan
-
[Excel dosyası oluşturan ve kullanılmayan isimli bir stil oluşturan aşağıdaki örnek kod. {0} true olarak ayarlandığından, bu kullanılmayan isimli stil çıktı HTML’sine dışa aktarılmayacaktır. Ancak, falseolarak ayarlarsanız, bu kullanılmayan stil çıktı HTML içinde bulunacaktır ve yukarıdaki ekran görüntüsünde HTML işaretleme dilinde görebilirsiniz.](/cells/tr/javascript-cpp/exclude-unused-styles-during-excel-to-html-conversion/)
-
Excel’den HTML’ye Databar, ColorScale ve IconSet Koşullu Biçimlendirmeyi Dışa Aktar
-
Excel’de belge çalışma kitabı ve çalışma sayfası özelliklerini HTML dönüşümünde dışa aktar
-
CrossHideRight ile Üzerine Binme Content’ini HTML’şe kaydederken Gizle
-
Web Tarayıcıları tarafından desteklenmeyen Birleşik Stil’in benzerini dışa aktar
-
HtmlSaveOptions.TableCssId özelliği ile Tablo Öğeleri Stillerini Ön Eklemek
-
HTML’ye Kaydetme İşlemi Sırasında Gizli Çalışsayfa İçeriğinin Dışa Aktarılmasını Engelle
-
Yayılan Elemanın Düzgünleşmiş Doldurmasını, Çalışma Kitaplarını HTML’e Dönüştürürken Renderle
-
Kolon genişliğini em veya yüzde gibi ölçeklenebilir birim olarak ayarlayın
-
HTML olarak elektronik tabloyu oluştururken varsayılan yazı tipini ayarlayın
-
Çıkış HTML’sinde dizeyi nasıl geçeceğini HtmlCrossType kullanarak belirtin
-
HTML’nin Excel elektronik tablosuna yüklenmesi sırasında DIV etiketlerinin düzenini destekle