Microsoft® Konversi Dokumen Excel melalui C++

Simpan Microsoft® file Excel sebagai format spreadsheet, web, gambar, dan tata letak tetap

 

Untuk aplikasi atau solusi pengonversi spreadsheet apa pun,C++ Perpustakaan Excel mempercepat proses pengkodean, otomatisasi, dan konversi saat menangani banyak file termasuk XLSX, XLS, XLSM, XLSB, XLTX, XLTM, CSV, SpreadsheetML, ODS. Ini juga memungkinkan untuk mengonversi Excel ke 0 76193481*, XPS, HTML, MHTML, Biasa Teks dan gambar populer seperti JPG, TIFF, PNG, BMP dan SVG.

Antar-konversi Format Excel Microsoft

Mengonversi antar format spreadsheet hanya memerlukan pemuatan spreadsheet menggunakan Buku Kerja kelas dan menyimpannya kembali dalam format yang diperlukan menggunakan Menyimpan metode Buku Kerja kelas.

C++ Contoh Kode Konversi Format File Excel

Aspose::Cells::Startup();

// Load the source excel format.
Workbook wkb(u"src_excel_file.xls");
// Save in required output format.
wkb.Save(u"output_excel_format.xlsx", SaveFormat::Xlsx);

Aspose::Cells::Cleanup();
 

Konversikan Format Excel ke PDF dengan Pengaturan Tingkat Kepatuhan

C++ Otomatisasi Excel API mendukung konversi Buku Kerja ke PDF serta mendukung pengaturan tingkat kepatuhan dan tanggal pembuatan. Pengembang dapat menggunakan OpsiSimpan Pdf bersama Aspose::Cells::Render untuk mengatur kepatuhan PDF. Untuk konversi, metode penyimpanan API memiliki PdfSaveOptions sebagai parameter dan jalur file keluaran tertentu.

C++ Contoh Kode Konversi Excel ke PDF

Aspose::Cells::Startup();

// Load the sample Excel file.
Workbook wkb(u"sample-convert-excel-to.pdf");
// Create pdf save options object.
PdfSaveOptions pdfSaveOptions;

// Set the compliance to PDF/A-1b.
pdfSaveOptions.SetCompliance(PdfCompliance::PdfA1b);

// or PdfCompliance::PdfA1a
// for normal PDF it will be PdfCompliance::None

// Save the Excel Document in PDF format
wkb.Save(u"output-converted-excel-workbook-to.pdf", pdfSaveOptions);

Aspose::Cells::Cleanup();
 

Simpan Excel ke Gambar

C++ Pengurai Excel memiliki kemampuan untuk mengekspor data dalam bentuk gambar. Setiap lembar kerja dapat dikonversi ke format gambar yang berbeda termasuk BMP, JPEG, PNG dan GIF, diatur oleh Render::ImageOrPrintOptions . Untuk apa punKonversi Excel ke Gambar kasus, pilih kasus yang relevan dari tautan.

C++ Kode Konversi Excel ke Gambar

Aspose::Cells::Startup();

// Load the XLSX.
Aspose::Cells::Workbook wkb(u"source-excel-file.xlsx");

// Access first worksheet.
Aspose::Cells::Worksheet wks = wkb.GetWorksheets().Get(0);

// Create image or print options object.
Aspose::Cells::Rendering::ImageOrPrintOptions imgOptions;

// Specify the image format. Below code is for JPEG
imgOptions.SetImageType(ImageType::Jpeg);

// For other images like GIF, BMP and PNG one can use ImageType::Gif, ImageType::Bmp and ImageType::Png respectively 

// Specify horizontal and vertical resolution
imgOptions.SetHorizontalResolution(200);
imgOptions.SetVerticalResolution(200);

// Render the sheet with respect to specified image or print options.
Aspose::Cells::Rendering::SheetRender sr(wks, imgOptions);

// Get page count.
int pageCount = sr.GetPageCount();

std::string sb = "";
// Render each page to jpeg image one by one.
for (int i = 0; i < pageCount; i++) {
	sb = ""; 
	sb += "ImagesOutputDirectoryPath/";
	sb += "outputConvertingWorksheetToImageJPEG_";
	sb += std::to_string(i);
	sb += ".jpeg";
	// Get the output image path.
	U16String outputJPEG(sb.c_str());
	// Convert worksheet to image.
	sr.ToImage(i, outputJPEG);
}

Aspose::Cells::Cleanup();