Microsoft® แปลงเอกสาร Excel ผ่านทาง C++
บันทึกไฟล์ Excel Microsoft® เป็นไฟล์สเปรดชีต เว็บ รูปภาพ และรูปแบบคงที่
สำหรับแอปพลิเคชันหรือโซลูชันตัวแปลงสเปรดชีตC++ เอ็กเซล ไลบรารี่ เพิ่มความเร็วให้กับกระบวนการเขียนโค้ด ระบบอัตโนมัติ และการแปลงในขณะที่จัดการไฟล์หลายไฟล์ รวมถึง XLSX, XLS, XLSM, XLSB, XLTX, XLTM, CSV, SpreadsheetML, ODS นอกจากนี้ยังช่วยให้ แปลง Excel เป็น PDF*, XPS, HTML, MHTML, ธรรมดา ข้อความและรูปภาพยอดนิยม เช่น JPG, TIFF, PNG, BMP และ SVG.
การแปลงรูปแบบ Excel Microsoft ระหว่างกัน
การแปลงระหว่างรูปแบบสเปรดชีตต้องการเพียงการโหลดสเปรดชีตโดยใช้ สมุดงาน และบันทึกใหม่ในรูปแบบที่ต้องการโดยใช้ บันทึก วิธีการของ สมุดงาน ระดับ.
C++ ตัวอย่างโค้ดสำหรับการแปลงรูปแบบไฟล์ 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();
แปลงรูปแบบ Excel เป็น PDF ด้วยการตั้งค่าระดับการปฏิบัติตามข้อกำหนด
C++ Excel Automation API รองรับการแปลงเวิร์กบุ๊กเป็น PDF รวมถึงรองรับการตั้งค่าระดับการปฏิบัติตามข้อกำหนดและวันที่สร้าง นักพัฒนาสามารถใช้งานได้ ตัวเลือก PdfSave พร้อมด้วย Aspose::Cells::กำลังเรนเดอร์ เพื่อตั้งค่าการปฏิบัติตาม PDF สำหรับการแปลง API วิธีการบันทึกที่มี PdfSaveOptions เป็นพารามิเตอร์และเส้นทางไฟล์เอาต์พุตที่ระบุ
โค้ดตัวอย่าง C++ สำหรับการแปลง Excel เป็น 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();
บันทึก Excel ลงในรูปภาพ
C++ เอกเซลพาร์เซอร์ มีความสามารถในการส่งออกข้อมูลในรูปแบบรูปภาพ แต่ละเวิร์กชีตสามารถแปลงเป็นรูปแบบรูปภาพที่แตกต่างกัน ได้แก่ BMP, JPEG, PNG และ GIF ซึ่งกำหนดโดย การแสดงผล::ImageOrPrintOptions . สำหรับอย่างใดอย่างหนึ่งแปลง Excel เป็นรูปภาพ กรณี ให้เลือกกรณีที่เกี่ยวข้องจากลิงก์
C++ รหัสสำหรับการแปลง Excel เป็นรูปภาพ
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();