Microsoft® Excel Document Conversion with Go via C++
Save Microsoft® Excel files as spreadsheet, web, image and fixed-layout formats
For any spreadsheet converter application or solution, Go via C++ Excel Library speeds up coding, automation and conversion processes while handling multiple files including XLSX, XLS, XLSM, XLSB, XLTX, XLTM, CSV, SpreadsheetML, ODS. It also allows to convert Excel to PDF, XPS, HTML, MHTML, Plain Text and popular images such as JPG, TIFF, PNG, BMP and SVG.
Inter-conversion of Microsoft Excel Formats
Converting between spreadsheet formats only requires loading the spreadsheet using the Workbook class and re-saving it in the required format using the Save method of the Workbook class.
Go via C++ Example Code for Excel File Format Conversion
package main
import (
. "github.com/Aspose-Cells/aspose-cells-go-cpp/v25"
)
// Load the source excel format.
workbook,_:= NewWorkbook_String("src_excel_file.xlsx")
// Save in required output format.
workbook.Save_String("output_excel_format.xlsx")
Convert Excel Formats to PDF with Compliance Level Settings
Go via C++ Excel Automation API supports conversion of Workbooks to PDF as well as support setting of compliance level and creation date. Developers can use PdfSaveOptions to set the PDF compliance. For conversion, API save method having PdfSaveOptions as parameter and speicified output file path.
Go via C++ Sample Code for Excel to PDF Conversion
package main
import (
. "github.com/Aspose-Cells/aspose-cells-go-cpp/v25"
)
workbook, _ := NewWorkbook()
worksheets, _ := workbook.GetWorksheets()
worksheet, _ := worksheets.Get_Int(0)
cells, _ := worksheet.GetCells()
cell, _ := cells.Get_String("A1")
cell.PutValue_Int(5)
cell, _ = cells.Get_String("A2")
cell.PutValue_Int(15)
cell, _ = cells.Get_String("A3")
cell.PutValue_Int(25)
workbook.Save_String("HELLO_Convert.pdf")
println("Finish to convert to PDF , check .pdf file in output folder.")
Save Excel to Images
Go via C++ Excel Parser has the ability to export data in the form of images. Each worksheet can be converted to different image formats including BMP, JPEG, PNG and GIF, set by the Rendering::ImageOrPrintOptions . For any Convert Excel to Images case, select the relevant case from links.
Go via C++ Code for Excel to Image Conversion
package main
import (
. "github.com/Aspose-Cells/aspose-cells-go-cpp/v25"
)
// Load the XLSX.
workbook, _ := NewWorkbook("source-excel-file.xlsx")
// Access first worksheet.
worksheets, _ := workbook.GetWorksheets()
worksheet, _ := worksheets.Get_Int(0)
// Create image or print options object.
imgOptions, _ := NewImageOrPrintOptions()
// Specify the image format. Below code is for JPEG
imgOptions.SetImageType(ImageType_Jpeg)
// Specify horizontal and vertical resolution
imgOptions.SetHorizontalResolution(200)
imgOptions.SetVerticalResolution(200)
// Render the sheet with respect to specified image or print options.
sheetRender, _ := NewSheetRender(worksheet, imgOptions)
// Get page count.
pageCount, _ := sheetRender.GetPageCount()
// Render each page to jpeg image one by one.
for i := int32(0); i < pageCount; i++ {
data, _ := sheetRender.ToImage_Int(i)
filename := "Image" + string(i) + ".jpg"
file, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
defer file.Close()
file.Write(data)
}