Last active
October 10, 2025 03:51
-
-
Save aspose-cells-gists/b414abd53259bbc47d2c3c0fe985395b to your computer and use it in GitHub Desktop.
Aspose.Cells for Go via C++
This gist exceeds the recommended number of files (~10).
To access all files, please clone this gist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func SetComment() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| comments, _ := worksheet.GetComments() | |
| comment_index, _ := comments.Add_String("A1") | |
| println("Get comment index:") | |
| comment, _ := comments.Get_Int(comment_index) | |
| comment.SetNote("Hello, World!") | |
| workbook.Save_String("../Data/Output/HELLO_Comment.xlsx") | |
| println("Finish to set comment, check HELLO_Comment.xlsx file in output folder.") | |
| } | |
| func main() { | |
| SetComment() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func SetComment() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| comments, _ := worksheet.GetComments() | |
| comment_index, _ := comments.Add_String("A1") | |
| println("Get comment index:") | |
| comment, _ := comments.Get_Int(comment_index) | |
| comment.SetNote("Hello, World!") | |
| workbook.Save_String("../Data/Output/HELLO_Comment.ods") | |
| println("Finish to set comment, check HELLO_Comment.ods file in output folder.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func SetComment() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| comments, _ := worksheet.GetComments() | |
| comment_index, _ := comments.Add_String("A1") | |
| println("Get comment index:") | |
| comment, _ := comments.Get_Int(comment_index) | |
| comment.SetNote("Hello, World!") | |
| workbook.Save_String("../Data/Output/HELLO_Comment.xls") | |
| println("Finish to set comment, check HELLO_Comment.xls file in output folder.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func SetComment() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| comments, _ := worksheet.GetComments() | |
| comment_index, _ := comments.Add_String("A1") | |
| println("Get comment index:") | |
| comment, _ := comments.Get_Int(comment_index) | |
| comment.SetNote("Hello, World!") | |
| workbook.Save_String("../Data/Output/HELLO_Comment.xlsb") | |
| println("Finish to set comment, check HELLO_Comment.xlsb file in output folder.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func SetComment() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| comments, _ := worksheet.GetComments() | |
| comment_index, _ := comments.Add_String("A1") | |
| println("Get comment index:") | |
| comment, _ := comments.Get_Int(comment_index) | |
| comment.SetNote("Hello, World!") | |
| workbook.Save_String("../Data/Output/HELLO_Comment.xlsx") | |
| println("Finish to set comment, check HELLO_Comment.xlsx file in output folder.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func SetComment() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| comments, _ := worksheet.GetComments() | |
| comment_index, _ := comments.Add_String("A1") | |
| println("Get comment index:") | |
| comment, _ := comments.Get_Int(comment_index) | |
| comment.SetNote("Hello, World!") | |
| workbook.Save_String("../Data/Output/HELLO_Comment.xltm") | |
| println("Finish to set comment, check HELLO_Comment.xltm file in output folder.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func AddCustomProperty() { | |
| workbook, _ := NewWorkbook() | |
| customDocumentProperties, _ := workbook.GetCustomDocumentProperties() | |
| customDocumentProperties.Add_String_String("MyCustom5", "This is my custom five.") | |
| workbook.Save_String("../Data/Output/HELLO_CustomDocumentPropertie.xlsx") | |
| println("Finish to add custom properties, check HELLO_CustomDocumentPropertie.xlsx file in output folder.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This Gist contains code example snippets for Aspose.Cells for Go via C++. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| cell, _ = cells.Get_String("A4") | |
| cell.SetFormula_String("=SUM(A1:A3)") | |
| workbook.CalculateFormula() | |
| println(cell.GetIntValue()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Pyramid, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| series, _ := chart.GetNSeries() | |
| series.Add_String_Bool("A1:B3", true) | |
| workbook.Save_String("CreateChart.xlsx") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create a new workbook. | |
| workbook, _ := NewWorkbook() | |
| // Load a workbook from a file. | |
| workbook, _ := NewWorkbook_String("Book1.xlsx") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| type ReportGenerator struct { | |
| workbook *Workbook | |
| worksheet *Worksheet | |
| } | |
| type SaleRecord struct { | |
| Date time.Time | |
| Product string | |
| Quantity int32 | |
| Price float64 | |
| } | |
| func (reportGenerator *ReportGenerator) initialization() { | |
| reportGenerator.workbook, _ = NewWorkbook() | |
| worksheets, _ := reportGenerator.workbook.GetWorksheets() | |
| reportGenerator.worksheet, _ = worksheets.Get_Int(0) | |
| } | |
| func NewReportGenerator() *ReportGenerator { | |
| reportGenerator := &ReportGenerator{} | |
| reportGenerator.initialization() | |
| return reportGenerator | |
| } | |
| func (reportGenerator *ReportGenerator) GenerateSaleReport(records []SaleRecord) { | |
| reportGenerator.setupReportHeader() | |
| reportGenerator.fillSalesData(records) | |
| reportGenerator.addSummaryStatistics(records) | |
| reportGenerator.createCharts(records) | |
| reportGenerator.formatReport() | |
| } | |
| func (reportGenerator *ReportGenerator) createHeaderStyle() *Style { | |
| style, _ := reportGenerator.workbook.CreateStyle() | |
| font, _ := style.GetFont() | |
| font.SetIsBold(true) | |
| font.SetSize(16) | |
| style.SetHorizontalAlignment(TextAlignmentType_Center) | |
| return style | |
| } | |
| func (reportGenerator *ReportGenerator) setupReportHeader() { | |
| cells, _ := reportGenerator.worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Sales Report") | |
| cell.SetStyle_Style(reportGenerator.createHeaderStyle()) | |
| cells.Merge_Int_Int_Int_Int(0, 0, 1, 5) | |
| } | |
| func (reportGenerator *ReportGenerator) fillSalesData(saleRecords []SaleRecord) { | |
| headers := []string{"date", "product", "Quantity", "Unit Price", "Total Amount"} | |
| cells, _ := reportGenerator.worksheet.GetCells() | |
| rows, _ := cells.GetRows() | |
| row, _ := rows.Get(2) | |
| for i := 0; i < len(headers); i++ { | |
| cell, _ := row.Get(int32(i)) | |
| cell.PutValue_String(headers[i]) | |
| } | |
| var rowIndex int32 = 3 | |
| for i, record := range saleRecords { | |
| row, _ := rows.Get(rowIndex + int32(i)) | |
| cell, _ := row.Get(0) | |
| cell.PutValue_Date(record.Date) | |
| cell, _ = row.Get(1) | |
| cell.PutValue_String(record.Product) | |
| cell, _ = row.Get(2) | |
| cell.PutValue_Int(record.Quantity) | |
| cell, _ = row.Get(3) | |
| cell.PutValue_Double(record.Price) | |
| cell, _ = row.Get(4) | |
| print(rowIndex + int32(i)) | |
| cell.SetFormula_String(fmt.Sprintf("=C%d*D%d", rowIndex+int32(i)+1, rowIndex+int32(i)+1)) | |
| } | |
| } | |
| func (reportGenerator *ReportGenerator) addSummaryStatistics(records []SaleRecord) { | |
| dataRowCount := len(records) | |
| summaryRow := dataRowCount + 4 | |
| cells, _ := reportGenerator.worksheet.GetCells() | |
| cell, _ := cells.Get_Int_Int(int32(summaryRow), 0) | |
| cell.PutValue_String("Summary Statistics:") | |
| cell, _ = cells.Get_Int_Int(int32(summaryRow)+1, 0) | |
| cell.PutValue_String("Total Sales:") | |
| cell, _ = cells.Get_Int_Int(int32(summaryRow)+1, 1) | |
| cell.SetFormula_String(fmt.Sprintf("=SUM(E4:E%d)", dataRowCount+3)) | |
| cell, _ = cells.Get_Int_Int(int32(summaryRow)+2, 0) | |
| cell.PutValue_String("Average Sales:") | |
| cell, _ = cells.Get_Int_Int(int32(summaryRow)+2, 1) | |
| cell.SetFormula_String(fmt.Sprintf("=AVERAGE(E4:E%d)", dataRowCount+3)) | |
| } | |
| func (reportGenerator *ReportGenerator) createCharts(records []SaleRecord) { | |
| chartRow := int32(len(records) + 8) | |
| charts, _ := reportGenerator.worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, chartRow, 0, chartRow+10, 5) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| nseries, _ := chart.GetNSeries() | |
| nseries.Add_String_Bool(fmt.Sprintf("=Sheet1!$E$4:$E$%d", len(records)+3), true) | |
| nseries.SetCategoryData(fmt.Sprintf("=Sheet1!$B$4:$B$%d", len(records)+3)) | |
| chart_title, _ := chart.GetTitle() | |
| chart_title.SetText("Product sales comparison") | |
| } | |
| func (reportGenerator *ReportGenerator) formatReport() { | |
| // Set column width | |
| cells, _ := reportGenerator.worksheet.GetCells() | |
| cells.SetColumnWidth(0, 15) | |
| cells.SetColumnWidth(1, 20) | |
| cells.SetColumnWidth(2, 10) | |
| cells.SetColumnWidth(3, 10) | |
| cells.SetColumnWidth(4, 12) | |
| // Set number Format | |
| numberStyle, _ := reportGenerator.workbook.CreateStyle() | |
| numberStyle.SetCustom_String("#,##0.00") | |
| columns, _ := cells.GetColumns() | |
| column, _ := columns.Get(3) | |
| column.SetStyle(numberStyle) | |
| column, _ = columns.Get(4) | |
| column.SetStyle(numberStyle) | |
| } | |
| func (reportGenerator *ReportGenerator) SaveReport(filePath string) { | |
| reportGenerator.workbook.Save_String(filePath) | |
| } | |
| func GenerateReport() { | |
| t1, _ := time.ParseInLocation("2006-01-02", "2024-01-01", time.Local) | |
| t2, _ := time.ParseInLocation("2006-01-02", "2024-01-02", time.Local) | |
| t3, _ := time.ParseInLocation("2006-01-02", "2024-01-03", time.Local) | |
| records := []SaleRecord{ | |
| {t1, "Product A", 100, 25.5}, | |
| {t2, "Product B", 150, 30.0}, | |
| {t3, "Product A", 80, 25.5}, | |
| } | |
| generator := NewReportGenerator() | |
| generator.GenerateSaleReport(records) | |
| generator.SaveReport("Data/Output/SalesAnalysisReport.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| go mod init main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| lic, _ := NewLicense() | |
| lic.SetLicense_String("YOUR_LICENSE_File_PATH") | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String_Bool("Hello World!", true) | |
| style, _ := cell.GetStyle() | |
| style.SetPattern(BackgroundType_Solid) | |
| color, _ := NewColor() | |
| color.Set_Color_R(uint8(255)) | |
| color.Set_Color_G(uint8(128)) | |
| style.SetForegroundColor(color) | |
| cell.SetStyle_Style(style) | |
| workbook.Save_String("HELLO.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create a new workbook. | |
| workbook, err1 := NewWorkbook() | |
| if err1 != nil { | |
| print(err1) | |
| } | |
| // Get worksheets. | |
| worksheets, err2 := workbook.GetWorksheets() | |
| if err2 != nil { | |
| print(err2) | |
| } | |
| // Get worksheets based on indexes. | |
| worksheet, err3 := worksheets.Get_Int(0) | |
| if err3 != nil { | |
| print(err3) | |
| } | |
| //Get cells. | |
| cells, err4 := worksheet.GetCells() | |
| if err4 != nil { | |
| print(err4) | |
| } | |
| //Get cell based on cell name. | |
| cell, _ := cells.Get_String("A1") | |
| // Set string value for cell. | |
| cell.PutValue_String("Hello World!") | |
| cell, _ = cells.Get_String("A3") | |
| //Set integer value for cell. | |
| cell.PutValue_Int(1) | |
| //Get cell style. | |
| style, _ := cell.GetStyle() | |
| //Set number format. | |
| style.SetNumber(14) | |
| //Set cell style. | |
| cell.SetStyle_Style(style) | |
| cell, _ = cells.Get_String("B3") | |
| //Set the double value for the cell. | |
| cell.PutValue_Double(1.1201) | |
| cell, _ = cells.Get_String("C3") | |
| //Set the boolean value for the cell. | |
| cell.PutValue_Bool(true) | |
| cell, _ := cells.Get_String("A1") | |
| //Get the string value form the cell. | |
| value, _ := cell.GetStringValue() | |
| print(value) | |
| //Save the workbook to the disk. | |
| workbook.Save_String("HelloWorld.xlsx") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Load Excel file. | |
| workbook, _ := NewWorkbook_String("Book1.xlsx") | |
| //1. Save the workbook to the disk. | |
| workbook.Save_String("Book1.pdf") | |
| //2. Saves Excel file to a MemoryStream object and returns it. | |
| stream, err := workbook.Save_SaveFormat(SaveFormat_Pdf) | |
| if err != nil { | |
| log.Fatalf("Failed to read file: %v", err) | |
| } | |
| file, err1 := os.OpenFile("Book2.pdf", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) | |
| if err1 != nil { | |
| log.Fatalf("Failed to open file: %v", err1) | |
| } | |
| defer file.Close() | |
| _, err = file.Write(stream) | |
| if err != nil { | |
| log.Fatalf("Failed to append to file: %v", err) | |
| } | |
| //3. Saves an Excel file with a PDF save option. | |
| pdfSaveOptions, _ := NewPdfSaveOptions() | |
| pdfSaveOptions.SetCompliance(PdfCompliance_Pdf15) | |
| data, _ := workbook.Save_String_SaveOptions("security.pdf", pdfSaveOptions.ToSaveOptions()) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func ChartToImage() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| set_cell_int_value(cells, "A1", 50) | |
| set_cell_int_value(cells, "A2", 100) | |
| set_cell_int_value(cells, "A3", 150) | |
| set_cell_int_value(cells, "B1", 4) | |
| set_cell_int_value(cells, "B2", 20) | |
| set_cell_int_value(cells, "B3", 50) | |
| charts, _ := worksheet.GetCharts() | |
| charts.AddFloatingChart(ChartType_Pyramid, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(0) | |
| chart.ToImage_String_ImageType("../Data/Output/ChartToImage.png", ImageType_Png) | |
| println("Chart to png, and save as ChartToImage.png.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func CreateChartInExcel() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Pyramid, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| series, _ := chart.GetNSeries() | |
| series.Add_String_Bool("A1:B3", true) | |
| workbook.Save_String("../Data/Output/Hello_CreateChart.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func CreateChartInExcel() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Pyramid, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| series, _ := chart.GetNSeries() | |
| series.Add_String_Bool("A1:B3", true) | |
| workbook.Save_String("../Data/Output/Hello_CreateChart.ods") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func CreateChartInExcel() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Pyramid, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| series, _ := chart.GetNSeries() | |
| series.Add_String_Bool("A1:B3", true) | |
| workbook.Save_String("../Data/Output/Hello_CreateChart.xls") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func CreateChartInExcel() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Pyramid, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| series, _ := chart.GetNSeries() | |
| series.Add_String_Bool("A1:B3", true) | |
| workbook.Save_String("../Data/Output/Hello_CreateChart.xlsb") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func CreateChartInExcel() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Pyramid, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| series, _ := chart.GetNSeries() | |
| series.Add_String_Bool("A1:B3", true) | |
| workbook.Save_String("../Data/Output/Hello_CreateChart.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func CreateChartInExcel() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Pyramid, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| series, _ := chart.GetNSeries() | |
| series.Add_String_Bool("A1:B3", true) | |
| workbook.Save_String("../Data/Output/Hello_CreateChart.xltm") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Load the sample Excel file | |
| inputFilePath := "sampleAccessAndModifyLabelOfOleObject.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access first Ole Object | |
| oleObjects, _ := ws.GetOleObjects() | |
| oleObject, _ := oleObjects.Get(0) | |
| // Display the Label of the Ole Object | |
| label, _ := oleObject.GetLabel() | |
| fmt.Printf("Ole Object Label - Before: %s\n", label) | |
| // Modify the Label of the Ole Object | |
| oleObject.SetLabel("Aspose APIs") | |
| // Save workbook to memory stream | |
| ms, _ := wb.SaveToStream() | |
| // Set the workbook reference to null | |
| wb, _ = NewWorkbook() | |
| // Load workbook from memory stream | |
| wb, _ = NewWorkbook_Stream(ms) | |
| // Access first worksheet | |
| wss, _ = wb.GetWorksheets() | |
| ws, _ = wss.Get_Int(0) | |
| // Access first Ole Object | |
| oleObjects, _ = ws.GetOleObjects() | |
| oleObject, _ = oleObjects.Get(0) | |
| // Display the Label of the Ole Object that has been modified earlier | |
| label, _ = oleObject.GetLabel() | |
| fmt.Printf("Ole Object Label - After: %s\n", label) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook from source Excel file | |
| workbook, _ := NewWorkbook_String(srcDir + "source.xlsx") | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access cell D5 which lies inside the table | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("D5") | |
| // Put value inside the cell D5 | |
| cell.PutValue_String("D5 Data") | |
| // Access the Table from this cell | |
| table, _ := cell.GetTable() | |
| // Add some value using Row and Column Offset | |
| obj, _ := NewObject_String("Offset [2,2]") | |
| table.PutCellValue_Int_Int_Object(2, 2, obj) | |
| // Save the workbook | |
| workbook.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Workbook saved successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("sampleManageWorksheets.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| index, _ := worksheets.Add() | |
| worksheet, _ := worksheets.Get_Int(index) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("F7") | |
| value, _ := cell.GetStringValue() | |
| println(value) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create an object of the Workbook class | |
| wb, _ := NewWorkbook() | |
| // Access first worksheet from the collection | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add the TextBox to the worksheet | |
| textBoxes, _ := ws.GetTextBoxes() | |
| idx, _ := textBoxes.Add(10, 10, 10, 10) | |
| // Access newly created TextBox using its index & name it | |
| tb1, _ := textBoxes.Get_Int(idx) | |
| tb1.SetName("MyTextBox") | |
| // Set text for the TextBox | |
| tb1.SetText("This is MyTextBox") | |
| // Access the same TextBox via its name | |
| tb2, _ := textBoxes.Get_String("MyTextBox") | |
| // Display the text of the TextBox accessed via name | |
| text, _ := tb2.GetText() | |
| fmt.Println(text) | |
| fmt.Println("Press any key to continue...") | |
| fmt.Scanln() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook object | |
| wb, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add Toggle Button ActiveX Control inside the Shape Collection | |
| shapes, _ := ws.GetShapes() | |
| s, _ := shapes.AddActiveXControl(ControlType_ToggleButton, 4, 0, 4, 0, 100, 30) | |
| // Access the ActiveX control object and set its linked cell property | |
| c, _ := s.GetActiveXControl() | |
| c.SetLinkedCell("A1") | |
| // Save the workbook in xlsx format | |
| wb.Save_String_SaveFormat(outDir + "AddActiveXControls_out.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("ActiveX control added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of output excel file | |
| outputPath := outDir + "Output_out.xlsm" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the VBA project from the workbook | |
| vbaProj, _ := workbook.GetVbaProject() | |
| // Add registered references to the VBA project | |
| references, _ := vbaProj.GetReferences() | |
| references.AddRegisteredReference("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation") | |
| references.AddRegisteredReference("Office", "*\\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\MSO.DLL#Microsoft Office 14.0 Object Library") | |
| // Save the workbook | |
| workbook.Save_String(outputPath) | |
| fmt.Println("VBA project references added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Creating a Workbook object | |
| workbook, _ := NewWorkbook() | |
| // Obtaining the reference of the newly added worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Setting the values to the cells | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Count") | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("Price") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Apple") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Mango") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Blackberry") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Cherry") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(6) | |
| cell, _ = cells.Get_String("B5") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_Int(30) | |
| cell, _ = cells.Get_String("C5") | |
| cell.PutValue_Int(60) | |
| // Adding a PivotTable to the worksheet | |
| pivotTables, _ := ws.GetPivotTables() | |
| i, _ := pivotTables.Add_String_String_String("=A1:C5", "D10", "PivotTable1") | |
| // Accessing the instance of the newly added PivotTable | |
| pivotTable, _ := pivotTables.Get_Int(i) | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 0) | |
| // Adding a calculated field to PivotTable and dragging it to data area | |
| pivotTable.AddCalculatedField_String_String_Bool("total", "=Count*Price", true) | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| workbook.Save_String("out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create empty workbook | |
| wb, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Put some integer values in cell A1 and A2 | |
| cells, _ := ws.GetCells() | |
| cellA1, _ := cells.Get_String("A1") | |
| cellA1.PutValue_Int(10) | |
| cellA2, _ := cells.Get_String("A2") | |
| cellA2.PutValue_Int(30) | |
| // Access cell C1 and set its formula | |
| c1, _ := cells.Get_String("C1") | |
| c1.SetFormula_String("=Sum(A1,A2)") | |
| // Add cell C1 into cell watches by name | |
| watches, _ := ws.GetCellWatches() | |
| c1name, _ := c1.GetName() | |
| watches.Add_String(c1name) | |
| // Access cell E1 and set its formula | |
| e1, _ := cells.Get_String("E1") | |
| e1.SetFormula_String("=A2*A1") | |
| // Add cell E1 into cell watches by its row and column indices | |
| e1row, _ := e1.GetRow() | |
| e1col, _ := e1.GetColumn() | |
| watches, _ = ws.GetCellWatches() | |
| watches.Add_Int_Int(e1row, e1col) | |
| // Save workbook to output XLSX format | |
| wb.Save_String_SaveFormat("outputAddCellsToMicrosoftExcelFormulaWatchWindow.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiate a new Workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet (default worksheet) in the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Get the cells | |
| cells, _ := ws.GetCells() | |
| // Set the columns widths (A, B and C) | |
| cells.SetColumnWidth(0, 24) | |
| cells.SetColumnWidth(1, 24) | |
| cells.SetColumnWidth(2, 24) | |
| // Input date into the cells | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("KPIs") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Total Turnover (Sales at List)") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Total Gross Margin %") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Total Net Margin %") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("UA Contract Size Group 4") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(19551794) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Double(11.8070745566204) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Double(11.858589818569) | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("UA Contract Size Group 3") | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_Double(8150131.66666667) | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_Double(10.3168384396244) | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_Double(11.3326931937091) | |
| // Get the conditional icon's image data | |
| imagedata, _ := ConditionalFormattingIcon_GetIconImageData(IconSetType_TrafficLights31, 0) | |
| // Add the picture to the cell based on the image data | |
| pics, _ := ws.GetPictures() | |
| pics.Add_Int_Int_Stream(1, 1, imagedata) | |
| // Get the conditional icon's image data | |
| imagedata1, _ := ConditionalFormattingIcon_GetIconImageData(IconSetType_Arrows3, 2) | |
| // Add the picture to the cell based on the image data | |
| pics.Add_Int_Int_Stream(1, 2, imagedata1) | |
| // Get the conditional icon's image data | |
| imagedata2, _ := ConditionalFormattingIcon_GetIconImageData(IconSetType_Symbols3, 0) | |
| // Add the picture to the cell based on the image data | |
| pics.Add_Int_Int_Stream(2, 1, imagedata2) | |
| // Get the conditional icon's image data | |
| imagedata3, _ := ConditionalFormattingIcon_GetIconImageData(IconSetType_Stars3, 0) | |
| // Add the picture to the cell based on the image data | |
| pics.Add_Int_Int_Stream(2, 2, imagedata3) | |
| // Get the conditional icon's image data | |
| imagedata4, _ := ConditionalFormattingIcon_GetIconImageData(IconSetType_Boxes5, 1) | |
| // Add the picture to the cell based on the image data | |
| pics.Add_Int_Int_Stream(3, 1, imagedata4) | |
| // Get the conditional icon's image data | |
| imagedata5, _ := ConditionalFormattingIcon_GetIconImageData(IconSetType_Flags3, 1) | |
| // Add the picture to the cell based on the image data | |
| pics.Add_Int_Int_Stream(3, 2, imagedata5) | |
| // Save the Excel file | |
| outputPath := outDir + "outfile_cond_icons1.out.xlsx" | |
| workbook.Save_String(outputPath) | |
| fmt.Printf("File saved successfully at: %s\n", outputPath) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create empty workbook | |
| wb, _ := NewWorkbook() | |
| // Some data in the form of byte array | |
| // Please use correct XML and Schema instead | |
| btsData := []uint8{1, 2, 3} | |
| btsSchema := []uint8{1, 2, 3} | |
| // Create four custom xml parts | |
| customXmlParts, _ := wb.GetCustomXmlParts() | |
| customXmlParts.Add(btsData, btsSchema) | |
| customXmlParts.Add(btsData, btsSchema) | |
| customXmlParts.Add(btsData, btsSchema) | |
| customXmlParts.Add(btsData, btsSchema) | |
| // Assign ids to custom xml parts | |
| customXmlParts0, _ := customXmlParts.Get(0) | |
| customXmlParts0.SetID("Fruit") | |
| customXmlParts1, _ := customXmlParts.Get(1) | |
| customXmlParts1.SetID("Color") | |
| customXmlParts2, _ := customXmlParts.Get(2) | |
| customXmlParts2.SetID("Sport") | |
| customXmlParts3, _ := customXmlParts.Get(3) | |
| customXmlParts3.SetID("Shape") | |
| // Specify search custom xml part id | |
| srchID := "Fruit" | |
| srchID = "Color" | |
| srchID = "Sport" | |
| // Search custom xml part by the search id | |
| cxp, _ := customXmlParts.SelectByID(srchID) | |
| // Print the found or not found message on console | |
| isNull, _ := cxp.IsNull() | |
| if isNull { | |
| fmt.Printf("Not Found: CustomXmlPart ID %s\n", srchID) | |
| } else { | |
| fmt.Printf("Found: CustomXmlPart ID %s\n", srchID) | |
| } | |
| fmt.Println("AddCustomXMLPartsAndSelectThemByID executed successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source and output directories | |
| srcDir := "../Data/01_SourceDirectory/" | |
| outDir := "../Data/02_OutputDirectory/" | |
| // Certificate and workbook paths | |
| certFilePath := srcDir + "AsposeDemo.pfx" | |
| inputFilePath := srcDir + "sampleDigitallySignedByCells.xlsx" | |
| outputFilePath := outDir + "outputDigitallySignedByCells.xlsx" | |
| // Load digitally signed workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Create digital signature collection | |
| dsCollection, _ := NewDigitalSignatureCollection() | |
| // Create digital signature using PFX certificate | |
| password := "aspose" | |
| comments := "Aspose.Cells added new digital signature in existing digitally signed workbook." | |
| date := time.Now() | |
| signature, _ := NewDigitalSignature_String_String_String_Date(certFilePath, password, comments, date) | |
| // Add signature to collection | |
| dsCollection.Add(signature) | |
| // Apply digital signatures to workbook | |
| workbook.AddDigitalSignature(dsCollection) | |
| // Save modified workbook | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Digital signature added successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Set values to cells | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Count") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Apple") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Mango") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Blackberry") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Cherry") | |
| cell, _ = cells.Get_String("A6") | |
| cell.PutValue_String("Guava") | |
| cell, _ = cells.Get_String("A7") | |
| cell.PutValue_String("Carambola") | |
| cell, _ = cells.Get_String("A8") | |
| cell.PutValue_String("Banana") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(6) | |
| cell, _ = cells.Get_String("B5") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B6") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("B7") | |
| cell.PutValue_Int(2) | |
| cell, _ = cells.Get_String("B8") | |
| cell.PutValue_Int(20) | |
| // Add a PivotTable to the worksheet | |
| pivotTableCollection, _ := ws.GetPivotTables() | |
| i, _ := pivotTableCollection.Add_String_String_String("=A1:B8", "D10", "PivotTable1") | |
| // Access the instance of the newly added PivotTable | |
| pivotTable, _ := pivotTableCollection.Get_Int(i) | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 0) | |
| pivotTable.AddFieldToArea_PivotFieldType_String(PivotFieldType_Data, "Count") | |
| dataFields, _ := pivotTable.GetDataFields() | |
| dataField, _ := dataFields.Get_Int(0) | |
| dataField.SetFunction(ConsolidationFunction_Sum) | |
| rowFields, _ := pivotTable.GetRowFields() | |
| field, _ := rowFields.Get_Int(0) | |
| field.SetIsAutoSort(true) | |
| field.SetIsAscendSort(false) | |
| field.SetAutoSortField(0) | |
| // Add top10 filter | |
| rowFields, _ = pivotTable.GetRowFields() | |
| filterField, _ := rowFields.Get_Int(0) | |
| filterField.FilterTop10(0, PivotFilterType_Count, false, 5) | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| workbook.Save_String("out_add.xlsx") | |
| // Clear PivotFilter from the specific PivotField | |
| baseIndex, _ := field.GetBaseIndex() | |
| pivotFilters, _ := pivotTable.GetPivotFilters() | |
| pivotFilters.ClearFilter(baseIndex) | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| workbook.Save_String("out_delete.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Set values to cells | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Count") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Apple") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Mango") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Blackberry") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Cherry") | |
| cell, _ = cells.Get_String("A6") | |
| cell.PutValue_String("Guava") | |
| cell, _ = cells.Get_String("A7") | |
| cell.PutValue_String("Carambola") | |
| cell, _ = cells.Get_String("A8") | |
| cell.PutValue_String("Banana") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(6) | |
| cell, _ = cells.Get_String("B5") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("B6") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("B7") | |
| cell.PutValue_Int(2) | |
| cell, _ = cells.Get_String("B8") | |
| cell.PutValue_Int(20) | |
| // Add a PivotTable to the worksheet | |
| pivotTables, _ := ws.GetPivotTables() | |
| i, _ := pivotTables.Add_String_String_String("=A1:B8", "D10", "PivotTable1") | |
| // Access the instance of the newly added PivotTable | |
| pivotTable, _ := pivotTables.Get_Int(i) | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 0) | |
| pivotTable.AddFieldToArea_PivotFieldType_String(PivotFieldType_Data, "Count") | |
| dataFields, _ := pivotTable.GetDataFields() | |
| dataField, _ := dataFields.Get_Int(0) | |
| dataField.SetFunction(ConsolidationFunction_Sum) | |
| rowFields, _ := pivotTable.GetRowFields() | |
| field, _ := rowFields.Get_Int(0) | |
| field.SetIsAutoSort(true) | |
| field.SetIsAscendSort(false) | |
| field.SetAutoSortField(0) | |
| // Add top10 filter | |
| filterField, _ := rowFields.Get_Int(0) | |
| filterField.FilterTop10(0, PivotFilterType_Count, false, 5) | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| // Save the workbook | |
| workbook.Save_String("filterout.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiate a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Insert a string value to a cell | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("C2") | |
| cell.PutValue_String("Image Hyperlink") | |
| // Set the 4th row height | |
| cells.SetRowHeight(3, 100) | |
| // Set the C column width | |
| cells.SetColumnWidth(2, 21) | |
| // Add a picture to the C4 cell | |
| pics, _ := ws.GetPictures() | |
| index, _ := pics.Add_Int_Int_Int_Int_String(3, 2, 4, 3, srcDir+"aspose-logo.jpg") | |
| // Get the picture object | |
| pic, _ := pics.Get(index) | |
| // Set the placement type | |
| pic.SetPlacement(PlacementType_FreeFloating) | |
| // Add an image hyperlink | |
| hlink, _ := pic.AddHyperlink("http://www.aspose.com/") | |
| // Specify the screen tip | |
| hlink.SetScreenTip("Click to go to Aspose site") | |
| // Save the Excel file | |
| workbook.Save_String(outDir + "ImageHyperlink_out.xls") | |
| fmt.Println("Image hyperlink added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add some data in cells | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("2-Color Scale") | |
| cell, _ = cells.Get_String("D1") | |
| cell.PutValue_String("3-Color Scale") | |
| for i := int32(2); i <= 15; i++ { | |
| row := i - 1 | |
| cell, _ := cells.Get_Int_Int(row, 0) // Column A (0) | |
| cell.PutValue_Int(i) | |
| cell, _ = cells.Get_Int_Int(row, 3) // Column D (3) | |
| cell.PutValue_Int(i) | |
| } | |
| // Adding 2-Color Scale Conditional Formatting | |
| ca, _ := CellArea_CreateCellArea_String_String("A2", "A15") | |
| cfs, _ := ws.GetConditionalFormattings() | |
| idx, _ := cfs.Add() | |
| fcc, _ := cfs.Get(idx) | |
| fcc.AddCondition_FormatConditionType(FormatConditionType_ColorScale) | |
| fcc.AddArea(ca) | |
| fc, _ := fcc.Get(0) | |
| cs, _ := fc.GetColorScale() | |
| cs.SetIs3ColorScale(false) | |
| lightBlue, _ := Color_LightBlue() | |
| cs.SetMaxColor(lightBlue) | |
| lightGreen, _ := Color_LightGreen() | |
| cs.SetMinColor(lightGreen) | |
| // Adding 3-Color Scale Conditional Formatting | |
| ca, _ = CellArea_CreateCellArea_String_String("D2", "D15") | |
| cfs, _ = ws.GetConditionalFormattings() | |
| idx, _ = cfs.Add() | |
| fcc, _ = cfs.Get(idx) | |
| fcc.AddCondition_FormatConditionType(FormatConditionType_ColorScale) | |
| fcc.AddArea(ca) | |
| fc, _ = fcc.Get(0) | |
| cs, _ = fc.GetColorScale() | |
| cs.SetIs3ColorScale(true) | |
| cs.SetMaxColor(lightBlue) | |
| lightYellow, _ := Color_Yellow() | |
| cs.SetMidColor(lightYellow) | |
| cs.SetMinColor(lightGreen) | |
| // Save the workbook | |
| workbook.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Conditional formatting applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func AddCustomLabels() error { | |
| // Create workbook object | |
| workbook, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add sample data | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_Int_Int(0, 0) | |
| cell.PutValue_String("X") | |
| cell, _ = cells.Get_Int_Int(1, 0) | |
| cell.PutValue_Int(1) | |
| cell, _ = cells.Get_Int_Int(2, 0) | |
| cell.PutValue_Int(2) | |
| cell, _ = cells.Get_Int_Int(3, 0) | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_Int_Int(0, 1) | |
| cell.PutValue_String("Y") | |
| cell, _ = cells.Get_Int_Int(1, 1) | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_Int_Int(2, 1) | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_Int_Int(3, 1) | |
| cell.PutValue_Int(2) | |
| cell, _ = cells.Get_Int_Int(0, 2) | |
| cell.PutValue_String("Point Name") | |
| cell, _ = cells.Get_Int_Int(1, 2) | |
| cell.PutValue_String("Point A") | |
| cell, _ = cells.Get_Int_Int(2, 2) | |
| cell.PutValue_String("Point B") | |
| cell, _ = cells.Get_Int_Int(3, 2) | |
| cell.PutValue_String("Point C") | |
| // Add chart | |
| charts, _ := ws.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_ScatterConnectedByLinesWithDataMarker, 5, 0, 20, 8) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Set data source | |
| seriesCollection, _ := chart.GetNSeries() | |
| _, _ = seriesCollection.Add_String_Bool("=Sheet1!$B$2:$B$4", true) | |
| nseries, _ := seriesCollection.Get(0) | |
| nseries.SetXValues("=Sheet1!$A$2:$A$4") | |
| // Enable data labels | |
| dataLabels, _ := nseries.GetDataLabels() | |
| dataLabels.SetShowValue(true) | |
| // Add custom labels | |
| pointsCollection, _ := nseries.GetPoints() | |
| pointCount, _ := pointsCollection.GetCount() | |
| for i := int32(0); i < pointCount; i++ { | |
| point, _ := pointsCollection.Get(i) | |
| dataLabel, _ := point.GetDataLabels() | |
| seriesName, _ := nseries.GetName() | |
| cell, _ := cells.Get_Int_Int(i+1, 2) | |
| cellValue, _ := cell.GetStringValue() | |
| dataLabel.SetText(fmt.Sprintf("Series: %s\nPoint: %s", seriesName, cellValue)) | |
| } | |
| // Save workbook | |
| return workbook.Save_String("output.xlsx") | |
| } | |
| func main() { | |
| if err := AddCustomLabels(); err != nil { | |
| fmt.Println("Error:", err) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| outputPath := outDir + "output_out.xlsx" | |
| // Create workbook with XLSX format | |
| workbook, _ := NewWorkbook_FileFormatType(FileFormatType_Xlsx) | |
| wss, _ := workbook.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Populate data cells | |
| cells, _ := sheet.GetCells() | |
| cell, _ := cells.Get_Int_Int(0, 0) | |
| cell.PutValue_Int(1) | |
| cell, _ = cells.Get_Int_Int(0, 1) | |
| cell.PutValue_Int(2) | |
| cell, _ = cells.Get_Int_Int(0, 2) | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_Int_Int(1, 0) | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_Int_Int(1, 1) | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_Int_Int(1, 2) | |
| cell.PutValue_Int(6) | |
| cell, _ = cells.Get_Int_Int(2, 0) | |
| cell.PutValue_Int(7) | |
| cell, _ = cells.Get_Int_Int(2, 1) | |
| cell.PutValue_Int(8) | |
| cell, _ = cells.Get_Int_Int(2, 2) | |
| cell.PutValue_Int(9) | |
| // Create scatter chart | |
| charts, _ := sheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_ScatterConnectedByLinesWithDataMarker, 5, 1, 24, 10) | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Configure chart titles | |
| title, _ := chart.GetTitle() | |
| title.SetText("Test") | |
| categoryAxis, _ := chart.GetCategoryAxis() | |
| categoryTitle, _ := categoryAxis.GetTitle() | |
| categoryTitle.SetText("X-Axis") | |
| valueAxis, _ := chart.GetValueAxis() | |
| valueTitle, _ := valueAxis.GetTitle() | |
| valueTitle.SetText("Y-Axis") | |
| // Set category data range | |
| nSeries, _ := chart.GetNSeries() | |
| nSeries.SetCategoryData("A1:C1") | |
| // Add first data series | |
| nSeries.Add_String_Bool("A2:C2", false) | |
| series, _ := nSeries.Get(0) | |
| points, _ := series.GetPoints() | |
| pointCount, _ := points.GetCount() | |
| // Configure data labels for first series | |
| for i := int32(0); i < pointCount; i++ { | |
| point, _ := points.Get(i) | |
| labelText := fmt.Sprintf("Series 1\nPoint %d", i) | |
| dataLabels, _ := point.GetDataLabels() | |
| dataLabels.SetText(labelText) | |
| } | |
| // Add second data series | |
| nSeries.Add_String_Bool("A3:C3", false) | |
| series, _ = nSeries.Get(1) | |
| points, _ = series.GetPoints() | |
| pointCount, _ = points.GetCount() | |
| // Configure data labels for second series | |
| for i := int32(0); i < pointCount; i++ { | |
| point, _ := points.Get(i) | |
| labelText := fmt.Sprintf("Series 2\nPoint %d", i) | |
| dataLabels, _ := point.GetDataLabels() | |
| dataLabels.SetText(labelText) | |
| } | |
| // Save workbook | |
| workbook.Save_String(outputPath) | |
| fmt.Println("Chart created successfully with data labels!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Create workbook object with specified format | |
| workbook, _ := NewWorkbook_FileFormatType(FileFormatType_Xlsx) | |
| // Add simple property without any type | |
| contentTypeProperties, _ := workbook.GetContentTypeProperties() | |
| contentTypeProperties.Add_String_String("MK31", "Simple Data") | |
| // Add date time property with type | |
| contentTypeProperties.Add_String_String_String("MK32", "04-Mar-2015", "DateTime") | |
| // Save the workbook | |
| workbook.Save_String(srcDir + "AddingCustomPropertiesVisible_out.xlsx") | |
| fmt.Println("Custom properties added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(10) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(70) | |
| cell, _ = cells.Get_String("A4") | |
| cell.SetFormula_String("=SUM(A1:A3)") | |
| workbook.Save_String("outputAddingFormulasAndCalculatingResults.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| worksheet.AddPageBreaks("J20") | |
| workbook.Save_String("outputManagingPageBreaks.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| index, _ := worksheets.Add() | |
| worksheet, _ := worksheets.Get_Int(index) | |
| worksheet.SetName("My Worksheet") | |
| workbook.Save_String("outputManageWorksheets.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load source Excel file | |
| wb, _ := NewWorkbook_String(srcDir + "samplePdfBookmarkEntry_DestinationName.xlsx") | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access cell C5 | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("C5") | |
| // Create Bookmark and Destination for this cell | |
| bookmarkEntry, _ := NewPdfBookmarkEntry() | |
| bookmarkEntry.SetText("Text") | |
| bookmarkEntry.SetDestination(cell) | |
| cellName, _ := cell.GetName() | |
| bookmarkEntry.SetDestinationName("AsposeCells--" + cellName) | |
| // Access cell G56 | |
| cell, _ = cells.Get_String("G56") | |
| // Create Sub-Bookmark and Destination for this cell | |
| subbookmarkEntry1, _ := NewPdfBookmarkEntry() | |
| subbookmarkEntry1.SetText("Text1") | |
| subbookmarkEntry1.SetDestination(cell) | |
| cellName, _ = cell.GetName() | |
| subbookmarkEntry1.SetDestinationName("AsposeCells--" + cellName) | |
| // Access cell L4 | |
| cell, _ = cells.Get_String("L4") | |
| // Create Sub-Bookmark and Destination for this cell | |
| subbookmarkEntry2, _ := NewPdfBookmarkEntry() | |
| subbookmarkEntry2.SetText("Text2") | |
| subbookmarkEntry2.SetDestination(cell) | |
| cellName, _ = cell.GetName() | |
| subbookmarkEntry2.SetDestinationName("AsposeCells--" + cellName) | |
| // Add Sub-Bookmarks in list | |
| list := make([]*PdfBookmarkEntry, 0) | |
| list = append(list, subbookmarkEntry1, subbookmarkEntry2) | |
| // Assign Sub-Bookmarks list to Bookmark Sub-Entry | |
| // Note: The SubEntry property is not directly available in the provided headers. | |
| // Assuming it is a member of PdfBookmarkEntry, you would need to set it here. | |
| // bookmarkEntry.SetSubEntry(list); // This will be implemented when the function is available | |
| // Create PdfSaveOptions and assign Bookmark to it | |
| opts, _ := NewPdfSaveOptions() | |
| opts.SetBookmark(bookmarkEntry) | |
| // Save the workbook in Pdf format with given pdf save options | |
| wb.Save_String(outDir + "outputPdfBookmarkEntry_DestinationName.pdf") | |
| fmt.Println("Workbook saved successfully with bookmarks!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "os" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| data, _ := os.ReadFile("watermark.png") | |
| worksheet.SetBackgroundImage(data) | |
| workbook.Save_String("Watermark_Pict.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| // removed unused variable | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := "..\\Data\\01_SourceDirectory\\" + "add-pivot-connection.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "add-pivot-connection-out.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the first PivotTable inside the PivotTable collection | |
| pivotTables, _ := worksheet.GetPivotTables() | |
| pivotTable, _ := pivotTables.Get_Int(0) | |
| // Access the first slicer inside the slicer collection | |
| slicers, _ := worksheet.GetSlicers() | |
| slicer, _ := slicers.Get_Int(0) | |
| // Add PivotTable connection | |
| slicer.AddPivotConnection(pivotTable) | |
| // Save the workbook | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("PivotTable connection added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| wb, _ := NewWorkbook() | |
| signatureLine, _ := NewSignatureLine() | |
| signatureLine.SetSigner("Aspose.Cells") | |
| signatureLine.SetTitle("signed by Aspose.Cells") | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| shapes, _ := ws.GetShapes() | |
| shapes.AddSignatureLine(1, 1, signatureLine) | |
| certificatePath := srcDir + "rsa2048.pfx" | |
| password := "123456" | |
| now := time.Now() | |
| currentDate := now // Directly assign the time.Time | |
| signature, _ := NewDigitalSignature_String_String_String_Date(certificatePath, password, "test Microsoft Office signature line", currentDate) | |
| dsCollection, _ := NewDigitalSignatureCollection() | |
| dsCollection.Add(signature) | |
| wb.SetDigitalSignature(dsCollection) | |
| outputPath := srcDir + "signatureLine.xlsx" | |
| wb.Save_String(outputPath) | |
| fmt.Println("Workbook with signature line saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "../Data/02_OutputDirectory/" | |
| // Create an object of the Workbook class | |
| workbook, _ := NewWorkbook() | |
| // Access first worksheet from the collection | |
| wss, _ := workbook.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Add the TextBox to the worksheet | |
| textBoxes, _ := sheet.GetTextBoxes() | |
| textBoxes.Add(6, 10, 100, 200) | |
| // Save the workbook with the text box | |
| workbook.Save_String_SaveFormat(outDir + "result.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("Text box added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a workbook with 3 pages | |
| wb, _ := NewWorkbook() | |
| cells, _ := wb.GetWorksheets() | |
| ws0, _ := cells.Get_Int(0) | |
| ws0Cells, _ := ws0.GetCells() | |
| cellA1, _ := ws0Cells.Get_String("A1") | |
| cellA1.PutValue_String("Page1") | |
| index, _ := cells.Add() | |
| ws1, _ := cells.Get_Int(index) | |
| ws1Cells, _ := ws1.GetCells() | |
| cellA1, _ = ws1Cells.Get_String("A1") | |
| cellA1.PutValue_String("Page2") | |
| index, _ = cells.Add() | |
| ws2, _ := cells.Get_Int(index) | |
| ws2Cells, _ := ws2.GetCells() | |
| cellA1, _ = ws2Cells.Get_String("A1") | |
| cellA1.PutValue_String("Page3") | |
| pageSetup, _ := ws2.GetPageSetup() | |
| pageSetup.SetPaperSize(PaperSizeType_PaperA3) | |
| // Create a watermark from image (prepare image bytes) | |
| imageBytes := make([]uint8, 0) // Assume image bytes are prepared | |
| watermark, _ := NewRenderingWatermark_Stream(imageBytes) | |
| // Specify offset to alignment | |
| watermark.SetOffsetX(100) | |
| watermark.SetOffsetY(200) | |
| // Specify rotation | |
| watermark.SetRotation(30) | |
| // Specify watermark to background | |
| watermark.SetIsBackground(true) | |
| // Specify opacity | |
| watermark.SetOpacity(0.6) | |
| // Specify the scale to page (e.g., 100, 50) in percent | |
| watermark.SetScaleToPagePercent(50) | |
| // Specify watermark for rendering to PDF | |
| options, _ := NewPdfSaveOptions() | |
| options.SetWatermark(watermark) | |
| // Save the workbook with the watermark | |
| wb.Save_String_SaveOptions("output_image_watermark.pdf", options.ToSaveOptions()) | |
| fmt.Println("Workbook saved with watermark successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Prepare a workbook with 3 pages. | |
| wb, _ := NewWorkbook() | |
| cells, _ := wb.GetWorksheets() | |
| ws, _ := cells.Get_Int(0) | |
| wscells, _ := ws.GetCells() | |
| cell, _ := wscells.Get_String("A1") | |
| cell.PutValue_String("Page1") | |
| index, _ := cells.Add() | |
| ws, _ = cells.Get_Int(index) | |
| wscells, _ = ws.GetCells() | |
| cell, _ = wscells.Get_String("A1") | |
| cell.PutValue_String("Page2") | |
| index, _ = cells.Add() | |
| ws, _ = cells.Get_Int(index) | |
| wscells, _ = ws.GetCells() | |
| cell, _ = wscells.Get_String("A1") | |
| cell.PutValue_String("Page3") | |
| pageSetup, _ := ws.GetPageSetup() | |
| pageSetup.SetPaperSize(PaperSizeType_PaperA3) | |
| // Create a font for watermark, and specify bold, italic, color. | |
| font, _ := NewRenderingFont("Calibri", 68) | |
| font.SetItalic(true) | |
| font.SetBold(true) | |
| blue, _ := Color_Blue() | |
| font.SetColor(blue) | |
| // Create a watermark from text and the specified font. | |
| watermark, _ := NewRenderingWatermark_String_RenderingFont("Watermark", font) | |
| // Specify horizontal and vertical alignment. | |
| watermark.SetHAlignment(TextAlignmentType_Center) | |
| watermark.SetVAlignment(TextAlignmentType_Center) | |
| // Specify rotation. | |
| watermark.SetRotation(30) | |
| // Specify opacity. | |
| watermark.SetOpacity(0.6) | |
| // Specify the scale to page (e.g., 100, 50) in percent. | |
| watermark.SetScaleToPagePercent(50) | |
| // Specify watermark for rendering to PDF. | |
| options, _ := NewPdfSaveOptions() | |
| options.SetWatermark(watermark) | |
| // Save the workbook with the watermark. | |
| wb.Save_String_SaveOptions("output_text_watermark.pdf", options.ToSaveOptions()) | |
| fmt.Println("Workbook saved with watermark successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook object | |
| wb, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add Word Art Text with Built-in Styles | |
| shapes, _ := ws.GetShapes() | |
| shapes.AddWordArt(PresetWordArtStyle_WordArtStyle1, "Aspose File Format APIs", 0, 0, 0, 0, 100, 800) | |
| shapes.AddWordArt(PresetWordArtStyle_WordArtStyle2, "Aspose File Format APIs", 10, 0, 0, 0, 100, 800) | |
| shapes.AddWordArt(PresetWordArtStyle_WordArtStyle3, "Aspose File Format APIs", 20, 0, 0, 0, 100, 800) | |
| shapes.AddWordArt(PresetWordArtStyle_WordArtStyle4, "Aspose File Format APIs", 30, 0, 0, 0, 100, 800) | |
| shapes.AddWordArt(PresetWordArtStyle_WordArtStyle5, "Aspose File Format APIs", 40, 0, 0, 0, 100, 800) | |
| // Save the workbook in xlsx format | |
| wb.Save_String_SaveFormat(outDir + "output_out.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("WordArt added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| shapes, _ := worksheet.GetShapes() | |
| wordart, _ := shapes.AddTextEffect(MsoPresetTextEffect_TextEffect1, "CONFIDENTIAL", "Arial Black", 50, false, true, 18, 8, 1, 1, 130, 800) | |
| wordArtFormat, _ := wordart.GetFill() | |
| wordArtFormat.SetTransparency(0.9) | |
| workbook.Save_String("Watermark_Text.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Path to the documents directory. | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open the existing excel file. | |
| workbook, _ := NewWorkbook_String("..\\Data\\01_SourceDirectory\\sample.xlsx") | |
| // Get the chart in the first worksheet. | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| charts, _ := ws.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Add a WordArt watermark (shape) to the chart's plot area. | |
| shapes, _ := chart.GetShapes() | |
| wordart, _ := shapes.AddTextEffectInChart(MsoPresetTextEffect_TextEffect2, | |
| "CONFIDENTIAL", "Arial Black", 66, false, false, 1200, 500, 2000, 3000) | |
| // Get the shape's fill format. | |
| wordArtFormat, _ := wordart.GetFill() | |
| // Set the transparency. | |
| wordArtFormat.SetTransparency(0.9) | |
| // Get the line format. | |
| lineFormat, _ := wordart.GetLine() | |
| // Set Line format to invisible. | |
| lineFormat.SetWeight(0.0) | |
| // Save the excel file. | |
| workbook.Save_String(outputDir + "output_out.xlsx") | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| // Remove unused variable | |
| // Path of input XML file | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| inputXmlMap := srcDir + "sample.xml" | |
| // Create workbook object | |
| workbook, _ := NewWorkbook() | |
| // Add XML map found inside the sample.xml inside the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| xmlMaps, _ := wss.GetXmlMaps() | |
| xmlMaps.Add(inputXmlMap) // Changed Add_String to Add | |
| // Save the workbook in xlsx format | |
| outputFilePath := srcDir + "output_out.xlsx" | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Workbook saved successfully as xlsx format!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load the workbook | |
| workbook, _ := NewWorkbook_String(srcDir + "LargeSampleFile.xlsx") | |
| // Create XlsbSaveOptions object | |
| options, _ := NewXlsbSaveOptions() | |
| // Set compression level to 1 and save the workbook | |
| options.SetCompressionType(OoxmlCompressionType_Level1) | |
| start := time.Now() | |
| workbook.Save_String_SaveOptions(outDir + "LargeSampleFile_level_1_out.xlsb", options.ToSaveOptions()) | |
| duration := time.Since(start) | |
| fmt.Printf("Level 1 Elapsed Time: %v\n", duration.Milliseconds()) | |
| // Set compression level to 6 and save the workbook | |
| options.SetCompressionType(OoxmlCompressionType_Level6) | |
| start = time.Now() | |
| workbook.Save_String_SaveOptions(outDir + "LargeSampleFile_level_6_out.xlsb", options.ToSaveOptions()) | |
| duration = time.Since(start) | |
| fmt.Printf("Level 6 Elapsed Time: %v\n", duration.Milliseconds()) | |
| // Set compression level to 9 and save the workbook | |
| options.SetCompressionType(OoxmlCompressionType_Level9) | |
| start = time.Now() | |
| workbook.Save_String_SaveOptions(outDir + "LargeSampleFile_level_9_out.xlsb", options.ToSaveOptions()) | |
| duration = time.Since(start) | |
| fmt.Printf("Level 9 Elapsed Time: %v\n", duration.Milliseconds()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "Book1.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "output.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Accessing the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Lock the style of cell A1 | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| style, _ := cell.GetStyle() | |
| style.SetIsLocked(true) | |
| // Protect the sheet | |
| worksheet.Protect_ProtectionType(ProtectionType_All) | |
| // Save the workbook | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Worksheet protected successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "book1.xls" | |
| // Create workbook | |
| excel, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet in the Excel file | |
| wss, _ := excel.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Restricting users to delete columns of the worksheet | |
| protection, _ := worksheet.GetProtection() | |
| protection.SetAllowDeletingColumn(false) | |
| // Restricting users to delete row of the worksheet | |
| protection.SetAllowDeletingRow(false) | |
| // Restricting users to edit contents of the worksheet | |
| protection.SetAllowEditingContent(false) | |
| // Restricting users to edit objects of the worksheet | |
| protection.SetAllowEditingObject(false) | |
| // Restricting users to edit scenarios of the worksheet | |
| protection.SetAllowEditingScenario(false) | |
| // Restricting users to filter | |
| protection.SetAllowFiltering(false) | |
| // Allowing users to format cells of the worksheet | |
| protection.SetAllowFormattingCell(true) | |
| // Allowing users to format rows of the worksheet | |
| protection.SetAllowFormattingRow(true) | |
| // Allowing users to format columns of the worksheet | |
| protection.SetAllowFormattingColumn(true) | |
| // Allowing users to insert hyperlinks in the worksheet | |
| protection.SetAllowInsertingHyperlink(true) | |
| // Allowing users to insert rows in the worksheet | |
| protection.SetAllowInsertingRow(true) | |
| // Allowing users to select locked cells of the worksheet | |
| protection.SetAllowSelectingLockedCell(true) | |
| // Allowing users to select unlocked cells of the worksheet | |
| protection.SetAllowSelectingUnlockedCell(true) | |
| // Allowing users to sort | |
| protection.SetAllowSorting(true) | |
| // Allowing users to use pivot tables in the worksheet | |
| protection.SetAllowUsingPivotTable(true) | |
| // Save the modified Excel file | |
| outputFilePath := srcDir + "output.xls" | |
| newSaveFormat := SaveFormat_Excel97To2003 | |
| excel.Save_String_SaveFormat(outputFilePath, newSaveFormat) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Clearing all the worksheets | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheets.Clear() | |
| // Adding a new worksheet to the Excel object | |
| i, _ := worksheets.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| ws, _ := worksheets.Get_Int(i) | |
| // Accessing the "A1" cell from the worksheet | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Adding some value to the "A1" cell | |
| cell.PutValue_String("Visit Aspose!") | |
| // Setting the horizontal alignment of the text in the "A1" cell | |
| style, _ := cell.GetStyle() | |
| // Setting the vertical alignment of the text in a cell | |
| style.SetVerticalAlignment(TextAlignmentType_Center) | |
| cell.SetStyle_Style(style) | |
| // Saving the Excel file | |
| workbook.Save_String_SaveFormat(outDir + "book1.out.xls", SaveFormat_Excel97To2003) | |
| println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access the "A1" cell | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Set value in the cell | |
| cell.PutValue_String("Visit Aspose!") | |
| // Get the cell's style | |
| style, _ := cell.GetStyle() | |
| // Set the indentation level | |
| style.SetIndentLevel(2) | |
| // Apply the style to the cell | |
| cell.SetStyle_Style(style) | |
| // Save the workbook | |
| workbook.Save_String_SaveFormat(outDir + "book1.out.xls", SaveFormat_Excel97To2003) | |
| fmt.Println("File saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the "A1" cell | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Add value to the cell | |
| cell.PutValue_String("Visit Aspose!") | |
| // Get the cell's style | |
| style, _ := cell.GetStyle() | |
| // Set the rotation angle of the text to 25 degrees | |
| style.SetRotationAngle(25) | |
| // Apply the style to the cell | |
| cell.SetStyle_Style(style) | |
| // Save the workbook in Excel 97-2003 format | |
| workbook.Save_String_SaveFormat(outDir + "book1.out.xls", SaveFormat_Excel97To2003) | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create Workbook Object | |
| wb, _ := NewWorkbook() | |
| // Open first Worksheet in the workbook | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Get Worksheet Cells Collection | |
| cells, _ := ws.GetCells() | |
| // Increase the width of First Column Width | |
| cells.SetColumnWidth(0, 35) | |
| // Increase the height of first row | |
| cells.SetRowHeight(0, 36) | |
| // Add Text to the First Cell | |
| cell, _ := cells.Get_Int_Int(0, 0) | |
| cell.PutValue_String("I am using the latest version of Aspose.Cells to test this functionality") | |
| // Make Cell's Text wrap | |
| style, _ := cell.GetStyle() | |
| style.SetIsTextWrapped(true) | |
| cell.SetStyle_Style(style) | |
| // Save Excel File | |
| wb.Save_String(outDir + "WrappingText_out.xlsx") | |
| fmt.Println("Text wrapping applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the "A1" cell | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Add value to the cell | |
| cell.PutValue_String("Visit Aspose!") | |
| // Get the cell's style | |
| style, _ := cell.GetStyle() | |
| // Set shrink to fit | |
| style.SetShrinkToFit(true) | |
| // Apply the style to the cell | |
| cell.SetStyle_Style(style) | |
| // Save the workbook | |
| workbook.Save_String_SaveFormat(outDir + "book1.out.xls", SaveFormat_Excel97To2003) | |
| fmt.Println("File saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a Workbook | |
| wbk, _ := NewWorkbook() | |
| // Create a Worksheet and get the first sheet | |
| wss, _ := wbk.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Create a Cells object to fetch all the cells | |
| cells, _ := ws.GetCells() | |
| // Merge some Cells (C6:E7) into a single C6 Cell | |
| _ = cells.Merge_Int_Int_Int_Int(5, 2, 2, 3) | |
| // Input data into C6 Cell | |
| cellC6, _ := cells.Get_Int_Int(5, 2) | |
| cellC6.PutValue_String("This is my value") | |
| // Create a Style object to fetch the Style of C6 Cell | |
| style, _ := cellC6.GetStyle() | |
| // Create a Font object | |
| font, _ := style.GetFont() | |
| // Set the name | |
| font.SetName("Times New Roman") | |
| // Set the font size | |
| font.SetSize(18) | |
| // Set the font color | |
| blue, _ := Color_Blue() | |
| font.SetColor(blue) | |
| // Bold the text | |
| font.SetIsBold(true) | |
| // Make it italic | |
| font.SetIsItalic(true) | |
| // Set the background color of C6 Cell to Red | |
| red, _ := Color_Red() | |
| style.SetForegroundColor(red) | |
| style.SetPattern(BackgroundType_Solid) | |
| // Apply the Style to C6 Cell | |
| cellC6.SetStyle_Style(style) | |
| // Save the Workbook | |
| wbk.Save_String(outDir + "mergingcells.out.xls") | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access cell A1 | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Set value in cell A1 | |
| cell.PutValue_String("I am using the latest version of Aspose.Cells to test this functionality.") | |
| // Get the style of cell A1 | |
| style, _ := cell.GetStyle() | |
| // Set text direction to left-to-right | |
| style.SetTextDirection(TextDirectionType_LeftToRight) | |
| // Apply the modified style to the cell | |
| cell.SetStyle_Style(style) | |
| // Save the workbook | |
| workbook.Save_String("book1.xlsx") | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Obtain the reference of the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access the "A1" cell from the worksheet | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Add some value to the "A1" cell | |
| cell.PutValue_String("Visit Aspose!") | |
| // Set the horizontal alignment of the text in the "A1" cell | |
| style, _ := cell.GetStyle() | |
| style.SetHorizontalAlignment(TextAlignmentType_Center) | |
| cell.SetStyle_Style(style) | |
| // Save the Excel file | |
| workbook.Save_String_SaveFormat(outDir + "book1.out.xls", SaveFormat_Excel97To2003) | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Instantiate a workbook object and open the template file | |
| workbook, _ := NewWorkbook_String(srcDir + "Book1.xlsx") | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Get the A1 cell | |
| cells, _ := worksheet.GetCells() | |
| a1, _ := cells.Get_String("A1") | |
| // Get the conditional formatting resultant object | |
| cfr1, _ := a1.GetConditionalFormattingResult() | |
| // Get the ColorScale resultant color object | |
| _, _ = cfr1.GetColorScaleResult() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load your source workbook | |
| workbook, _ := NewWorkbook_String(sourceDir + "sampleAdvancedFilter.xlsx") | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Apply advanced filter on range A5:D19 and criteria range is A1:D2 | |
| // Besides, we want to filter in place | |
| // And, we want all filtered records not just unique records | |
| ws.Advanced_Filter(true, "A5:D19", "A1:D2", "", false) | |
| // Save the workbook in xlsx format | |
| workbook.Save_String_SaveFormat(outputDir + "outputAdvancedFilter.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("Advanced filter applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| // srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Adds an empty conditional formatting | |
| conditionalFormattings, _ := sheet.GetConditionalFormattings() | |
| index, _ := conditionalFormattings.Add() | |
| // Get the conditional formatting collection | |
| fcs, _ := conditionalFormattings.Get(index) | |
| // Sets the conditional format range | |
| ca, _ := CellArea_CreateCellArea_Int_Int_Int_Int(2, 1, 2, 1) | |
| // Add the area to the conditional formatting | |
| fcs.AddArea(ca) | |
| // Adds condition | |
| conditionIndex, _ := fcs.AddCondition_FormatConditionType(FormatConditionType_Expression) | |
| // Get the format condition | |
| fc, _ := fcs.Get(conditionIndex) | |
| // Set the formula for the condition | |
| fc.SetFormula1_String("=IF(SUM(B1:B2)>100,TRUE,FALSE)") | |
| // Set the background color | |
| style, _ := fc.GetStyle() | |
| red, _ := Color_Red() | |
| style.SetBackgroundColor(red) | |
| fc.SetStyle(style) | |
| // Set the formula for cell B3 | |
| cells, _ := sheet.GetCells() | |
| cellB3, _ := cells.Get_String("B3") | |
| cellB3.SetFormula_String("=SUM(B1:B2)") | |
| // Set the value for cell C4 | |
| cellC4, _ := cells.Get_String("C4") | |
| cellC4.PutValue_String("If Sum of B1:B2 is greater than 100, B3 will have RED background") | |
| // Save the Excel file | |
| workbook.Save_String(outDir + "output.out.xls") | |
| fmt.Println("Conditional formatting applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook from source Excel file | |
| workbook, _ := NewWorkbook_String(srcDir + "Book1.xlsx") | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Get the Cells collection in the first worksheet | |
| cells, _ := worksheet.GetCells() | |
| ca, _ := CellArea_CreateCellArea_String_String("A2", "B11") | |
| // Apply subtotal, the consolidation function is Sum and it will be applied to the Second column (B) in the list | |
| cells.Subtotal_CellArea_Int_ConsolidationFunction_int32Array_Bool_Bool_Bool(ca, 0, ConsolidationFunction_Sum, []int32{0}, true, false, true) | |
| // Set the direction of outline summary | |
| outline, _ := worksheet.GetOutline() | |
| outline.SetSummaryRowBelow(true) | |
| // Save the excel file | |
| workbook.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Subtotal applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "SampleTextboxExcel2016.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "Output.xlsx" | |
| // Initialize an object of the Workbook class to load template file | |
| sourceWb, _ := NewWorkbook_String(inputFilePath) | |
| // Access the target textbox whose text is to be aligned | |
| wss, _ := sourceWb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| shapes, _ := ws.GetShapes() | |
| sourceTextBox, _ := shapes.Get_Int(0) | |
| // Create an object of the target workbook | |
| destWb, _ := NewWorkbook() | |
| // Access first worksheet from the collection | |
| sheets, _ := destWb.GetWorksheets() | |
| sheet, _ := sheets.Get_Int(0) | |
| // Create new textbox | |
| shapesDest, _ := sheet.GetShapes() | |
| textBox, _ := shapesDest.AddShape(MsoDrawingType_TextBox, 1, 0, 1, 0, 200, 200) | |
| // Use Html string from a template file textbox | |
| htmlText, _ := sourceTextBox.GetHtmlText() | |
| textBox.SetHtmlText(htmlText) | |
| // Save the workbook on disc | |
| destWb.Save_String(outputFilePath) | |
| fmt.Println("Textbox copied and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the shapes collection from the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| shapes, _ := ws.GetShapes() | |
| // Add a TextBox to the worksheet | |
| shape, _ := shapes.AddTextBox(2, 0, 2, 0, 50, 120) | |
| // Set the text of the TextBox | |
| shape.SetText("This is a test.") | |
| // Set the horizontal and vertical alignment of the text | |
| shape.SetTextHorizontalAlignment(TextAlignmentType_Center) | |
| shape.SetTextVerticalAlignment(TextAlignmentType_Center) | |
| // Save the workbook to the output directory | |
| workbook.Save_String(outDir + "result.xlsx") | |
| fmt.Println("TextBox added and workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create an instance of Workbook | |
| book, _ := NewWorkbook() | |
| // Access the Worksheet on which desired rule has to be applied | |
| wss, _ := book.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add FormatConditions to the instance of Worksheet | |
| cfs, _ := ws.GetConditionalFormattings() // Get Conditional Formatting Collection | |
| idx, _ := cfs.Add() | |
| // Access the newly added FormatConditions via its index | |
| conditionCollection, _ := cfs.Get(idx) | |
| // Define a CellsArea on which conditional formatting will be applicable | |
| area, _ := CellArea_CreateCellArea_Int_Int_Int_Int(0, 0, 19, 8) // Handle the error return | |
| // Add area to the instance of FormatConditions | |
| conditionCollection.AddArea(area) | |
| // Add a condition to the instance of FormatConditions | |
| // For this case, the condition type is expression, which is based on some formula | |
| idx, _ = conditionCollection.AddCondition_FormatConditionType(FormatConditionType_Expression) | |
| // Access the newly added FormatCondition via its index | |
| formatCondition, _ := conditionCollection.Get(idx) | |
| // Set the formula for the FormatCondition | |
| formatCondition.SetFormula1_String("=MOD(ROW(),2)=0") // Use the correct method signature | |
| // Set the background color and pattern for the FormatCondition's Style | |
| style, _ := formatCondition.GetStyle() | |
| blue, _ := Color_Blue() // Handle the error return | |
| style.SetBackgroundColor(blue) | |
| style.SetPattern(BackgroundType_Solid) | |
| // Save the result on disk | |
| book.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Conditional formatting applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| wb, _ := NewWorkbook() | |
| // Add a new worksheet to the workbook | |
| worksheets, _ := wb.GetWorksheets() | |
| worksheets.Add() | |
| // Get the reference of the newly added worksheet by passing its sheet index | |
| wss, _ := wb.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the "A1" cell from the worksheet | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Add some value to the "A1" cell | |
| cell.PutValue_String("Hello") | |
| // Set the font Subscript | |
| style, _ := cell.GetStyle() | |
| font, _ := style.GetFont() | |
| font.SetIsSubscript(true) | |
| // Removed `cell.SetStyle(style)` as it's not a valid method | |
| // Save the Excel file | |
| wb.Save_String_SaveFormat(outDir + "Subscript_out.xls", SaveFormat_Auto) | |
| fmt.Println("File saved successfully with subscript text!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiating a Workbook object | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Excel object | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheets.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Accessing the "A1" cell from the worksheet | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Adding some value to the "A1" cell | |
| cell.PutValue_String("Hello") | |
| // Setting the font Superscript | |
| style, _ := cell.GetStyle() | |
| font, _ := style.GetFont() | |
| font.SetIsSuperscript(true) | |
| cell.SetStyle_Style(style) | |
| // Saving the Excel file | |
| workbook.Save_String_SaveFormat(outDir + "Superscript_out.xls", SaveFormat_Auto) | |
| fmt.Println("Excel file saved successfully with superscript text!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| vbaProject, _ := workbook.GetVbaProject() | |
| modules, _ := vbaProject.GetModules() | |
| module, _ := modules.Get_String("MyModule") // Changed to use Add_Module | |
| module.SetCodes( | |
| "Sub ShowMessage()\r\n" + | |
| " MsgBox \"Welcome to Aspose!\"\r\n" + | |
| "End Sub", | |
| ) | |
| shapes, _ := ws.GetShapes() | |
| button, _ := shapes.AddButton(2, 0, 2, 0, 28, 80) | |
| button.SetPlacement(PlacementType_FreeFloating) | |
| font, _ := button.GetFont() | |
| font.SetName("Tahoma") | |
| font.SetIsBold(true) | |
| blue, _ := Color_Blue() | |
| font.SetColor(blue) | |
| button.SetText("Aspose") | |
| sheetName, _ := ws.GetName() | |
| button.SetMacroName(sheetName + ".ShowMessage") | |
| outputPath := outDir + "Output.out.xlsm" | |
| workbook.Save_String(outputPath) | |
| fmt.Println("VBA button added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a Workbook | |
| inputFilePath := "range_autofill.xlsx" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Get Cells | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| // Create Range | |
| src, _ := cells.CreateRange_String("C3:C4") | |
| dest, _ := cells.CreateRange_String("C5:C10") | |
| // AutoFill - Need to retrieve the method correctly | |
| src.AutoFill_Range_AutoFillType(dest, AutoFillType_Series) | |
| // Save the Workbook | |
| outputFilePath := "range_autofill_result.xlsx" | |
| workbook.Save_String(outputFilePath) | |
| println("Range auto-filled successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Sample HTML string | |
| sampleHtml := "<html><body><table><tr><td>This is sample text.</td><td>Some text.</td></tr><tr><td>This is another sample text.</td><td>Some text.</td></tr></table></body></html>" | |
| // Convert HTML string to memory stream | |
| utf8Data := sampleHtml | |
| ms := make([]byte, len(utf8Data)) | |
| copy(ms, utf8Data) | |
| // Load memory stream into workbook | |
| wb, _ := NewWorkbook_Stream(ms) | |
| // Save the workbook in xlsx format | |
| wb.Save_String(outDir + "outputWithout_AutoFitColsAndRows.xlsx") | |
| // Specify the HTMLLoadOptions and set AutoFitColsAndRows = true | |
| opts, _ := NewHtmlLoadOptions() // Corrected to handle two return values | |
| opts.SetAutoFitColsAndRows(true) | |
| // Load memory stream into workbook with the above HTMLLoadOptions | |
| wbWithOptions, _ := NewWorkbook_Stream_LoadOptions(ms, opts.ToLoadOptions()) | |
| // Save the workbook in xlsx format | |
| wbWithOptions.Save_String(outDir + "outputWith_AutoFitColsAndRows.xlsx") | |
| fmt.Println("HTML to Excel conversion completed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Define the file path | |
| filePath := "..\\Data\\01_SourceDirectory\\" | |
| // Open an existing Excel file and save it as PDF | |
| wb, _ := NewWorkbook_String(filePath + "sample.xlsx") | |
| wb.Save_String(filePath + "out.pdf") | |
| // Set load options for the second workbook | |
| loadOptions, _ := NewLoadOptions() | |
| autoFitterOptions, _ := NewAutoFitterOptions() | |
| autoFitterOptions.SetOnlyAuto(true) | |
| loadOptions.SetAutoFitterOptions(autoFitterOptions) | |
| // Open the existing Excel file with load options and save it as PDF | |
| book, _ := NewWorkbook_String_LoadOptions(filePath + "sample.xlsx", loadOptions) | |
| book.Save_String(filePath + "out2.pdf") | |
| fmt.Println("PDF files created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "Book1.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "output.xlsx" | |
| // Open the Excel file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Accessing the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Auto-fit the 3rd row of the worksheet | |
| worksheet.AutoFitRow_Int(1) | |
| // Save the modified Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Row auto-fitted and file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| // srcDir := "..\\Data\\01_SourceDirectory\\" // removed unused variable | |
| // Path of input Excel file | |
| inputFilePath := "..\\Data\\01_SourceDirectory\\" + "Book1.xlsx" | |
| // Create workbook from the input file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Auto-fit the 5th column (index 4) from row 4 to 6 | |
| worksheet.AutoFitColumn_Int_Int_Int(4, 4, 6) | |
| // Save the modified Excel file | |
| outputFilePath := "..\\Data\\01_SourceDirectory\\" + "output.xlsx" | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Column auto-fitted and file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiate a new Workbook | |
| wb, _ := NewWorkbook() | |
| // Get the first (default) worksheet | |
| wss, _ := wb.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Create a range A1:B1 | |
| cells, _ := worksheet.GetCells() | |
| rangeObj, _ := cells.CreateRange_Int_Int_Int_Int(0, 0, 1, 2) | |
| // Merge the cells | |
| rangeObj.Merge() | |
| // Insert value to the merged cell A1 | |
| cell, _ := cells.Get_Int_Int(0, 0) | |
| cell.PutValue_String("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end") | |
| // Create a style object | |
| style, _ := cell.GetStyle() | |
| // Set wrapping text on | |
| style.SetIsTextWrapped(true) | |
| // Apply the style to the cell | |
| cell.SetStyle_Style(style) | |
| // Create an object for AutoFitterOptions | |
| options, _ := NewAutoFitterOptions() | |
| // Set auto-fit for merged cells | |
| options.SetAutoFitMergedCellsType(AutoFitMergedCellsType_EachLine) | |
| // Autofit rows in the sheet (including the merged cells) | |
| worksheet.AutoFitRows() | |
| // Save the Excel file | |
| wb.Save_String(outDir + "AutofitRowsforMergedCells.xlsx") | |
| fmt.Println("Autofit rows for merged cells completed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "Book1.xlsx" | |
| // Create workbook from file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Auto-fit the 2nd row (index 1) of the worksheet | |
| worksheet.AutoFitRow_Int(1) | |
| // Save the modified Excel file | |
| outputFilePath := srcDir + "output.xlsx" | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Row auto-fitted and file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| sheet1, _ := wss.Get_Int(0) | |
| // Create a range A1:B2 | |
| cells1, _ := sheet1.GetCells() | |
| range1, _ := cells1.CreateRange_Int_Int_Int_Int(0, 0, 2, 2) | |
| // Merge the cells | |
| range1.Merge() | |
| // Insert value to the merged cell A1 | |
| cell1, _ := cells1.Get_Int_Int(0, 0) | |
| cell1.PutValue_String("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end") | |
| // Create an object for Style | |
| style1, _ := cell1.GetStyle() | |
| // Set wrapping text on | |
| style1.SetIsTextWrapped(true) | |
| // Apply the style to the cell | |
| cell1.SetStyle_Style(style1) | |
| // Create an object for AutoFitterOptions | |
| options1, _ := NewAutoFitterOptions() | |
| // Only expands the height of the first row. | |
| options1.SetAutoFitMergedCellsType(AutoFitMergedCellsType_FirstLine) | |
| // Autofit rows in the sheet (including the merged cells) | |
| sheet1.AutoFitRows_AutoFitterOptions(options1) | |
| // Add a new worksheet | |
| index, _ := wss.Add() | |
| sheet2, _ := wss.Get_Int(index) | |
| sheet2.SetName("Sheet2") | |
| // Create a range A1:B2 | |
| cells2, _ := sheet2.GetCells() | |
| range2, _ := cells2.CreateRange_Int_Int_Int_Int(0, 0, 2, 2) | |
| // Merge the cells | |
| range2.Merge() | |
| // Insert value to the merged cell A1 | |
| cell2, _ := cells2.Get_Int_Int(0, 0) | |
| cell2.PutValue_String("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end") | |
| // Create an object for Style | |
| style2, _ := cell2.GetStyle() | |
| // Set wrapping text on | |
| style2.SetIsTextWrapped(true) | |
| // Apply the style to the cell | |
| cell2.SetStyle_Style(style2) | |
| // Create an object for AutoFitterOptions | |
| options2, _ := NewAutoFitterOptions() | |
| // Only expands the height of the last row. | |
| options2.SetAutoFitMergedCellsType(AutoFitMergedCellsType_LastLine) | |
| // Autofit rows in the sheet (including the merged cells) | |
| sheet2.AutoFitRows_AutoFitterOptions(options2) | |
| // Add another new worksheet | |
| index, _ = wss.Add() | |
| sheet3, _ := wss.Get_Int(index) | |
| sheet3.SetName("Sheet3") | |
| // Create a range A1:B2 | |
| cells3, _ := sheet3.GetCells() | |
| range3, _ := cells3.CreateRange_Int_Int_Int_Int(0, 0, 2, 2) | |
| // Merge the cells | |
| range3.Merge() | |
| // Insert value to the merged cell A1 | |
| cell3, _ := cells3.Get_Int_Int(0, 0) | |
| cell3.PutValue_String("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end") | |
| // Create an object for Style | |
| style3, _ := cell3.GetStyle() | |
| // Set wrapping text on | |
| style3.SetIsTextWrapped(true) | |
| // Apply the style to the cell | |
| cell3.SetStyle_Style(style3) | |
| // Create an object for AutoFitterOptions | |
| options3, _ := NewAutoFitterOptions() | |
| // Only expands the height of each row. | |
| options3.SetAutoFitMergedCellsType(AutoFitMergedCellsType_EachLine) | |
| // Autofit rows in the sheet (including the merged cells) | |
| sheet3.AutoFitRows_AutoFitterOptions(options3) | |
| // Add another new worksheet | |
| index, _ = wss.Add() | |
| sheet4, _ := wss.Get_Int(index) | |
| sheet4.SetName("Sheet4") | |
| // Create a range A1:B2 | |
| cells4, _ := sheet4.GetCells() | |
| range4, _ := cells4.CreateRange_Int_Int_Int_Int(0, 0, 2, 2) | |
| // Merge the cells | |
| range4.Merge() | |
| // Insert value to the merged cell A1 | |
| cell4, _ := cells4.Get_Int_Int(0, 0) | |
| cell4.PutValue_String("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end") | |
| // Create an object for Style | |
| style4, _ := cell4.GetStyle() | |
| // Set wrapping text on | |
| style4.SetIsTextWrapped(true) | |
| // Apply the style to the cell | |
| cell4.SetStyle_Style(style4) | |
| // Create an object for AutoFitterOptions | |
| options4, _ := NewAutoFitterOptions() | |
| // Ignore merged cells. | |
| options4.SetAutoFitMergedCellsType(AutoFitMergedCellsType_None) | |
| // Autofit rows in the sheet (not including the merged cells) | |
| sheet4.AutoFitRows_AutoFitterOptions(options4) | |
| // Save the Excel file | |
| workbook.Save_String("out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Initialize workbook instance | |
| workbook, _ := NewWorkbook_String("Book1.xlsx") | |
| // Set autofit options for rendering | |
| autoFitterOptions := new(AutoFitterOptions) | |
| autoFitterOptions.SetForRendering(true) | |
| // Autofit rows with options | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| ws.AutoFitRows_AutoFitterOptions(autoFitterOptions) | |
| // Save to PDF | |
| workbook.Save_String_SaveFormat("output.pdf", SaveFormat_Pdf) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Create workbook object from your sample excel file | |
| wb, _ := NewWorkbook_String(srcDir + "sample.xlsx") | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Set auto load property of first ole object to true | |
| oleObjects, _ := sheet.GetOleObjects() | |
| oleObject, _ := oleObjects.Get(0) | |
| oleObject.SetAutoLoad(true) | |
| // Save the workbook in xlsx format | |
| wb.Save_String_SaveFormat(srcDir + "RefreshOLEObjects_out.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("OLE object refreshed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| html := "<html><body><p>1234567890123456</p></body></html>" | |
| var byteArray []uint8 | |
| for i := 0; i < len(html); i++ { | |
| c := html[i] | |
| if c <= 0x7F { | |
| byteArray = append(byteArray, c) | |
| } | |
| } | |
| loadOptions, _ := NewHtmlLoadOptions() | |
| loadOptions.SetKeepPrecision(true) | |
| data := byteArray // Use the original byteArray directly | |
| workbook, _ := NewWorkbook_Stream(data) // Modified function call with correct number of arguments | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| ws.AutoFitColumns() | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| workbook.Save_String_SaveFormat(outDir + "outputAvoidExponentialNotationWhileImportingFromHtml.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("File saved successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Instantiating a Workbook object | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Workbook object | |
| wsCollection, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wsCollection.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wsCollection.Get_Int(sheetIndex) | |
| // Adding sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Series1") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Series2") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(60) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(32) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(50) | |
| // Adding a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Accessing the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B4" | |
| chart.SetChartDataRange("A1:B4", true) | |
| // Hiding X axis | |
| categoryAxis, _ := chart.GetCategoryAxis() | |
| categoryAxis.SetIsVisible(false) | |
| // Setting max value of Y axis | |
| valueAxis, _ := chart.GetValueAxis() | |
| maxValue := float64(200.0) | |
| doubleObject, _ := NewObject_Double(maxValue) | |
| valueAxis.SetMaxValue(doubleObject) | |
| // Setting major unit | |
| majorUnit := float64(50.0) | |
| valueAxis.SetMajorUnit(majorUnit) | |
| // Save the file | |
| workbook.Save_String("chart_axes.xlsx") | |
| } | |
| func float64Pointer(f float64) *float64 { | |
| return &f | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Obtain the reference of the first (default) worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Accessing the "A1" cell from the worksheet | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Adding some value to the "A1" cell | |
| cell.PutValue_String("Hello World From Aspose") | |
| // Creating a range of cells starting from "A1" cell to 3rd column in a row | |
| rangeObj, _ := cells.CreateRange_Int_Int_Int_Int(0, 0, 1, 3) | |
| color_blue, _ := Color_Blue() | |
| // Adding a thick top border with blue line | |
| rangeObj.SetOutlineBorders_CellBorderType_Color(CellBorderType_Thick, color_blue) | |
| // Adding a thick bottom border with blue line | |
| rangeObj.SetOutlineBorders_CellBorderType_Color(CellBorderType_Thick, color_blue) | |
| // Adding a thick left border with blue line | |
| rangeObj.SetOutlineBorders_CellBorderType_Color(CellBorderType_Thick, color_blue) | |
| // Adding a thick right border with blue line | |
| rangeObj.SetOutlineBorders_CellBorderType_Color(CellBorderType_Thick, color_blue) | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "book1.out.xls") | |
| fmt.Println("Excel file created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Visit Aspose!") | |
| style, _ := cell.GetStyle() | |
| borders, _ := style.GetBorders() | |
| topBorder, _ := borders.Get(BorderType_TopBorder) | |
| topBorder.SetLineStyle(CellBorderType_Thick) | |
| color_black, _ := Color_Black() | |
| topBorder.SetColor(color_black) | |
| bottomBorder, _ := borders.Get(BorderType_BottomBorder) | |
| bottomBorder.SetLineStyle(CellBorderType_Thick) | |
| color_black, _ = Color_Black() | |
| bottomBorder.SetColor(color_black) | |
| leftBorder, _ := borders.Get(BorderType_LeftBorder) | |
| leftBorder.SetLineStyle(CellBorderType_Thick) | |
| color_black, _ = Color_Black() | |
| leftBorder.SetColor(color_black) | |
| rightBorder, _ := borders.Get(BorderType_RightBorder) | |
| rightBorder.SetLineStyle(CellBorderType_Thick) | |
| color_black, _ = Color_Black() | |
| rightBorder.SetColor(color_black) | |
| cell.SetStyle_Style(style) // Updated method to SetStyle_Style | |
| workbook.Save_String(outDir + "book1.out.xls") | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a workbook | |
| workbook, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Put 20 in cell A1 | |
| cells, _ := worksheet.GetCells() | |
| cellA1, _ := cells.Get_String("A1") | |
| cellA1.PutValue_Int(20) | |
| // Put 30 in cell A2 | |
| cellA2, _ := cells.Get_String("A2") | |
| cellA2.PutValue_Int(30) | |
| // Calculate the Sum of A1 and A2 | |
| results, _ := worksheet.CalculateFormula_String("=Sum(A1:A2)") | |
| // Print the output | |
| cellA1Value, _ := cellA1.GetStringValue() | |
| cellA2Value, _ := cellA2.GetStringValue() | |
| resultsValue, _ := results.ToString() | |
| fmt.Println("Value of A1: ", cellA1Value) | |
| fmt.Println("Value of A2: ", cellA2Value) | |
| fmt.Println("Result of Sum(A1:A2): ", resultsValue) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "time" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Load the template workbook | |
| wb, _ := NewWorkbook_String(srcDir + "book1.xls") | |
| // Print the time before formula calculation | |
| start := time.Now() | |
| println("Start time:", start.Format(time.RFC1123)) | |
| // Set the CreateCalcChain as true | |
| settings, _ := wb.GetSettings() | |
| formulaSettings, _ := settings.GetFormulaSettings() | |
| formulaSettings.SetEnableCalculationChain(true) | |
| // Calculate the workbook formulas | |
| wb.CalculateFormula() | |
| // Print the time after formula calculation | |
| end := time.Now() | |
| println("End time:", end.Format(time.RFC1123)) | |
| // Change the value of one cell | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("newvalue") | |
| // Re-calculate those formulas which depend on cell A1 | |
| wb.CalculateFormula() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Add a new worksheet to the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Get the reference of the newly added worksheet | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Add values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(1) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(2) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(3) | |
| // Add a SUM formula to cell A4 | |
| cell, _ = cells.Get_String("A4") | |
| cell.SetFormula_String("=SUM(A1:A3)") | |
| // Calculate the results of formulas | |
| workbook.CalculateFormula() | |
| // Get the calculated value of cell A4 | |
| cell, _ = cells.Get_String("A4") | |
| _ , _ = cell.GetStringValue() | |
| // Save the Excel file | |
| workbook.Save_String(outDir + "output.xls") | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create workbook object | |
| workbook, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Put some data in these cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A4") | |
| cell.PutValue_String("Test") | |
| cell, _ = cells.Get_String("S4") | |
| cell.PutValue_String("Test") | |
| // Set paper size | |
| pageSetup, _ := worksheet.GetPageSetup() | |
| pageSetup.SetPaperSize(PaperSizeType_PaperA4) | |
| // Set fit to pages wide as 1 | |
| pageSetup.SetFitToPagesWide(1) | |
| // Calculate page scale via sheet render | |
| options := new(ImageOrPrintOptions) | |
| sr, _ := NewSheetRender(worksheet, options) | |
| // Convert page scale double value to percentage | |
| pageScale, _ := sr.GetPageScale() | |
| strPageScale := fmt.Sprintf("%.2f%%", pageScale*100) | |
| // Write the page scale value | |
| fmt.Println(strPageScale) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| 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) | |
| cell, _ = cells.Get_String("A4") | |
| cell.SetFormula_String("=SUM(A1:A3)") | |
| workbook.CalculateFormula() | |
| value, _ := cell.GetIntValue() | |
| println(value) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("sampleCalculatingFormulasOnceOnly.xlsx") | |
| settings, _ := workbook.GetSettings() | |
| formulaSetting, _ := settings.GetFormulaSettings() | |
| formulaSetting.SetForceFullCalculation(true) | |
| workbook.CalculateFormula() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create new workbook | |
| workbook, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Add data for VLOOKUP | |
| cells, _ := worksheet.GetCells() | |
| cell1, _ := cells.Get_String("A1") | |
| cell1.PutValue_String("Apple") | |
| cell2, _ := cells.Get_String("A2") | |
| cell2.PutValue_String("Orange") | |
| cell3, _ := cells.Get_String("A3") | |
| cell3.PutValue_String("Banana") | |
| // Access cell A5 and A6 | |
| cellA5, _ := cells.Get_String("A5") | |
| cellA6, _ := cells.Get_String("A6") | |
| // Assign IFNA formula to A5 and A6 | |
| cellA5.SetFormula_String("=IFNA(VLOOKUP(\"Pear\",$A$1:$A$3,1,0),\"Not found\")") | |
| cellA6.SetFormula_String("=IFNA(VLOOKUP(\"Orange\",$A$1:$A$3,1,0),\"Not found\")") | |
| // Calculate the formula of workbook | |
| workbook.CalculateFormula() | |
| // Print the values of A5 and A6 | |
| valueA5, _ := cellA5.GetStringValue() | |
| valueA6, _ := cellA6.GetStringValue() | |
| fmt.Println(valueA5) | |
| fmt.Println(valueA6) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "DataTable.xlsx" | |
| // Create workbook from source excel file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // When you will put 100 in B1, then all Data Table values formatted as Yellow will become 120 | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("B1") | |
| cell.PutValue_Int(100) | |
| // Calculate formula, now it also calculates Data Table array formula | |
| workbook.CalculateFormula() | |
| // Save the workbook in pdf format | |
| workbook.Save_String(outDir + "output_out.pdf") | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load your source workbook containing MINIFS and MAXIFS functions | |
| workbook, _ := NewWorkbook_String(srcDir + "sampleMINIFSAndMAXIFS.xlsx") | |
| // Perform Aspose.Cells formula calculation | |
| workbook.CalculateFormula() | |
| // Save the calculations result in pdf format | |
| options := new(PdfSaveOptions) | |
| options.SetOnePagePerSheet(true) | |
| workbook.Save_String_SaveOptions(outDir+"outputMINIFSAndMAXIFS.pdf", options.ToSaveOptions()) | |
| fmt.Println("PDF saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| inputFilePath := srcDir + "book1.xls" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| maxRow, _ := cells.GetMaxDataRow() | |
| maxCol, _ := cells.GetMaxDataColumn() | |
| for row := int32(0); row <= maxRow; row++ { | |
| for col := int32(0); col <= maxCol; col++ { | |
| cell, _ := cells.Get_Int_Int(row, col) | |
| var stringValue string | |
| doubleValue := 0.0 | |
| boolValue := false | |
| cellType, _ := cell.GetType() | |
| switch cellType { | |
| case CellValueType_IsString: | |
| stringValue, _ = cell.GetStringValue() | |
| fmt.Println("String Value:", stringValue) | |
| case CellValueType_IsNumeric: | |
| doubleValue, _ = cell.GetDoubleValue() | |
| fmt.Println("Double Value:", doubleValue) | |
| case CellValueType_IsBool: | |
| boolValue, _ = cell.GetBoolValue() | |
| fmt.Println("Bool Value:", boolValue) | |
| case CellValueType_IsDateTime: | |
| stringValue, _ = cell.GetStringValue() | |
| fmt.Println("DateTime Value:", stringValue) | |
| case CellValueType_IsUnknown: | |
| stringValue, _ = cell.GetStringValue() | |
| fmt.Println("Unknown Value:", stringValue) | |
| case CellValueType_IsNull: | |
| // No operation for null | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| cellA1, _ := cells.Get_String("A1") | |
| cellA1.PutValue_String("Hello World") | |
| cellA2, _ := cells.Get_String("A2") | |
| cellA2.PutValue_Double(20.5) | |
| cellA3, _ := cells.Get_String("A3") | |
| cellA3.PutValue_Int(15) | |
| cellA4, _ := cells.Get_String("A4") | |
| cellA4.PutValue_Bool(true) | |
| cellA1Style, _ := cellA1.GetStyle() | |
| cellA1Style.SetNumber(15) | |
| cellA1.SetStyle_Style(cellA1Style) | |
| workbook.Save_String(outDir + "output.out.xls") | |
| fmt.Println("Data inserted and workbook saved successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Instantiate a Workbook object | |
| workbook, _ := NewWorkbook() | |
| // Obtain the reference of the newly added worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Setting the value to the cells | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Count") | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("Price") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Apple") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Mango") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Blackberry") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Cherry") | |
| c3, _ := cells.Get_String("C3") | |
| // Set HTML string for C3 cell | |
| c3.SetHtmlString("<b>test bold</b>") | |
| c4, _ := cells.Get_String("C4") | |
| // Set HTML string for C4 cell | |
| c4.SetHtmlString("<i>test italic</i>") | |
| // Get the HTML string of specific cell | |
| htmlStringC3, _ := c3.GetHtmlString() | |
| fmt.Println(htmlStringC3) | |
| htmlStringC4, _ := c4.GetHtmlString() | |
| fmt.Println(htmlStringC4) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Instantiating a Workbook object | |
| workbook, _ := NewWorkbook() | |
| // Obtaining the reference of the newly added worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Setting the value to the cells | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Count") | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("Price") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Apple") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Mango") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Blackberry") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Cherry") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(6) | |
| cell, _ = cells.Get_String("B5") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_Int(30) | |
| cell, _ = cells.Get_String("C5") | |
| cell.PutValue_Int(60) | |
| strObj ,_ := NewObject_String("A1") | |
| curr, _ := cells.Find_Object_Cell(strObj , nil) | |
| currRow, currCol := int32(0), int32(0) | |
| // Get row and column index of current cell | |
| currName, _ := curr.GetName() | |
| currRow, currCol, _ = CellsHelper_CellNameToIndex(currName) | |
| fmt.Printf("Row Index: %d Column Index: %d\n", currRow, currCol) | |
| // Get column name by column index | |
| columnName, _ := CellsHelper_ColumnIndexToName(currCol) | |
| // Get row name by row index | |
| rowName, _ := CellsHelper_RowIndexToName(currRow) | |
| fmt.Printf("Column Name: %s Row Name: %s\n", columnName, rowName) | |
| // Get column index by column name | |
| columnIndex, _ := CellsHelper_ColumnNameToIndex(columnName) | |
| // Get row index by row name | |
| rowIndex, _ := CellsHelper_RowNameToIndex(rowName) | |
| fmt.Printf("Column Index: %d Row Index: %d\n", columnIndex, rowIndex) | |
| // Assertions | |
| if columnIndex != currCol || rowIndex != currRow { | |
| fmt.Println("Assertion failed!") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Count") | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("Price") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Apple") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Mango") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Blackberry") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Cherry") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(6) | |
| cell, _ = cells.Get_String("B5") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_Int(30) | |
| cell, _ = cells.Get_String("C5") | |
| cell.PutValue_Int(60) | |
| cell, _ = cells.Get_String("E10") | |
| temp, _ := workbook.CreateStyle() | |
| font, _ := temp.GetFont() | |
| color, _ := Color_Red() | |
| font.SetColor(color) | |
| maxRow, _ := cells.GetMaxRow() | |
| fmt.Println(maxRow) | |
| maxDataRow, _ := cells.GetMaxDataRow() | |
| fmt.Println(maxDataRow) | |
| maxColumn, _ := cells.GetMaxColumn() | |
| fmt.Println(maxColumn) | |
| maxDataColumn, _ := cells.GetMaxDataColumn() | |
| fmt.Println(maxDataColumn) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // File path for saving the workbook | |
| filePath := "" | |
| // Create a new workbook | |
| wb, _ := NewWorkbook() | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add a RoundedRectangularCallout to the worksheet | |
| shapes, _ := ws.GetShapes() | |
| polygonShape, _ := shapes.AddAutoShape(AutoShapeType_RoundedRectangularCallout, 0, 0, 0, 0, 0, 0) | |
| polygonShape.SetY(200) // Shape Top properties | |
| polygonShape.SetX(500) // Shape Left properties | |
| polygonShape.SetWidth(200) // Shape Width | |
| polygonShape.SetHeight(100) // Shape Height | |
| geometry, _ := polygonShape.GetGeometry() | |
| shapeGuides, _ := geometry.GetShapeAdjustValues() | |
| shapeGuides.Add("adj1", 1.02167) // The distance between the tip point and the center point | |
| shapeGuides.Add("adj2", -0.295) // The distance between the tip point and the center point | |
| shapeGuides.Add("adj3", 0.16667) // Usually the default value | |
| // Save the workbook | |
| wb.Save_String(filePath + "res.xlsx") | |
| // Read a new workbook | |
| wb, _ = NewWorkbook_String(filePath + "res.xlsx") | |
| wss, _ = wb.GetWorksheets() | |
| ws, _ = wss.Get_Int(0) | |
| // Get a RoundedRectangularCallout from the worksheet | |
| shapes, _ = ws.GetShapes() | |
| polygonShape, _ = shapes.Get_Int(0) | |
| geometry, _ = polygonShape.GetGeometry() | |
| shapeGuides, _ = geometry.GetShapeAdjustValues() | |
| shapeGuide, _ := shapeGuides.Get(0) | |
| shapeGuide.SetValue(0.7) // Modify the first shape guide value | |
| // Save the workbook again | |
| wb.Save_String(filePath + "res-resave.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook object from source excel file | |
| inputFilePath := srcDir + "source.xlsx" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access first three shapes of the worksheet | |
| shapes, _ := worksheet.GetShapes() | |
| shape1, _ := shapes.Get_Int(0) | |
| shape2, _ := shapes.Get_Int(1) | |
| shape3, _ := shapes.Get_Int(2) | |
| // Change the adjustment values of the shapes | |
| geometry1, _ := shape1.GetGeometry() | |
| adjustValues1, _ := geometry1.GetShapeAdjustValues() | |
| adjustValue1, _ := adjustValues1.Get(0) | |
| adjustValue1.SetValue(0.5) | |
| geometry2, _ := shape2.GetGeometry() | |
| adjustValues2, _ := geometry2.GetShapeAdjustValues() | |
| adjustValue2, _ := adjustValues2.Get(0) | |
| adjustValue2.SetValue(0.8) | |
| geometry3, _ := shape3.GetGeometry() | |
| adjustValues3, _ := geometry3.GetShapeAdjustValues() | |
| adjustValue3, _ := adjustValues3.Get(0) | |
| adjustValue3.SetValue(0.5) | |
| // Save the workbook | |
| workbook.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Load sample Excel file containing cells with formatting. | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| wb, _ := NewWorkbook_String(sourceDir + "sampleChangeCellsAlignmentAndKeepExistingFormatting.xlsx") | |
| // Access first worksheet. | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Create cells range. | |
| cells, _ := ws.GetCells() | |
| rng, _ := cells.CreateRange_Int_Int_Int_Int(2, 1, 7, 3) // Corrected method to create the range | |
| // Create style object. | |
| st, _ := wb.CreateStyle() | |
| // Set the horizontal and vertical alignment to center. | |
| st.SetHorizontalAlignment(TextAlignmentType_Center) | |
| st.SetVerticalAlignment(TextAlignmentType_Center) | |
| // Create style flag object. | |
| flag, _ := NewStyleFlag() | |
| // Set style flag alignments true. It is the most crucial statement. | |
| // Because if it is false, no changes will take place. | |
| flag.SetAlignments(true) | |
| // Apply style to range of cells. | |
| rng.ApplyStyle(st, flag) | |
| // Save the workbook in XLSX format. | |
| wb.Save_String_SaveFormat(outputDir + "outputChangeCellsAlignmentAndKeepExistingFormatting.xlsx", SaveFormat_Xlsx) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load your excel file inside a workbook object | |
| wb, _ := NewWorkbook_String(srcDir + "sampleChangeTextBoxOrShapeCharacterSpacing.xlsx") | |
| // Access your text box which is also a shape object from shapes collection | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| shapes, _ := ws.GetShapes() | |
| shape, _ := shapes.Get_Int(0) | |
| // Access the first font setting object via GetCharacters() method | |
| richFormattings, _ := shape.GetRichFormattings() | |
| fs := richFormattings[0] // Accessing directly by index since Get method does not exist | |
| // Set the character spacing to point 4 | |
| textOptions, _ := fs.GetTextOptions() | |
| textOptions.SetSpacing(4) | |
| // Save the workbook in xlsx format | |
| newSaveOptions := SaveFormat_Xlsx | |
| wb.Save_String_SaveFormat(outDir + "outputChangeTextBoxOrShapeCharacterSpacing.xlsx", newSaveOptions) | |
| fmt.Println("Character spacing changed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Load sample Excel file | |
| wb, _ := NewWorkbook_String(srcDir + "sample.xlsx") | |
| // Access the first sheet which contains chart | |
| wss, _ := wb.GetWorksheets() | |
| source, _ := wss.Get_Int(0) | |
| // Add another sheet named DestSheet | |
| destination, _ := wss.Add_String("DestSheet") | |
| // Set CopyOptions.ReferToDestinationSheet to true | |
| options := new(CopyOptions) | |
| options.SetReferToDestinationSheet(true) | |
| // Copy all the rows of source worksheet to destination worksheet which includes chart as well | |
| // The chart data source will now refer to DestSheet | |
| cellsSource, _ := source.GetCells() | |
| cellsDestination, _ := destination.GetCells() | |
| maxDisplayRange, _ := cellsSource.GetMaxDisplayRange() | |
| rowCount, _ := maxDisplayRange.GetRowCount() | |
| cellsDestination.CopyRows_Cells_Int_Int_Int(cellsSource, 0, 0, rowCount) | |
| // Save workbook in xlsx format | |
| wb.Save_String_SaveFormat(srcDir + "output_out.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Count") | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("Price") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Apple") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Mango") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Blackberry") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Cherry") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(6) | |
| cell, _ = cells.Get_String("B5") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_Int(5) | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_Int(20) | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_Int(30) | |
| cell, _ = cells.Get_String("C5") | |
| cell.PutValue_Int(60) | |
| worksheet0, _ := wss.Get_Int(0) | |
| cells0, _ := worksheet0.GetCells() | |
| cellA2, _ := cells0.Get_String("A2") | |
| style, _ := cellA2.GetStyle() | |
| font, _ := style.GetFont() | |
| color_red, _ := Color_Red() | |
| font.SetColor(color_red) | |
| font.SetIsBold(true) | |
| flag := new(StyleFlag) | |
| flag.SetFontColor(true) | |
| cellA2.SetStyle_Style(style) | |
| cellB3, _ := cells0.Get_String("B3") | |
| style2, _ := cellB3.GetStyle() | |
| font2, _ := style2.GetFont() | |
| color_blue, _ := Color_Blue() | |
| font2.SetColor(color_blue) | |
| font2.SetIsItalic(true) | |
| cellB3.SetStyle_Style(style2) | |
| workbook.Save_String("output.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| "io/ioutil" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Go | |
| // Load sample Excel file containing a table. | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| options, _ := NewLoadOptions() // Initialize LoadOptions as needed | |
| fileData, _ := ioutil.ReadFile(sourceDir + "sampleCreateSlicerToExcelTable.xlsx") | |
| workbook, _ := NewWorkbook_Stream_LoadOptions(fileData, options) | |
| // Access first worksheet. | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access first table inside the worksheet. | |
| listObjects, _ := worksheet.GetListObjects() | |
| listObject, _ := listObjects.Get_Int(0) // Use the returned value to avoid unused variable error | |
| // Add slicer | |
| slicerCollection, _ := worksheet.GetSlicers() | |
| idx, _ := slicerCollection.Add_ListObject_Int_String(listObject, 0, "H5") | |
| slicer, _ := slicerCollection.Get_Int(idx) | |
| slicer.SetPlacement(PlacementType_FreeFloating) | |
| slicer.SetRowHeightPixel(50) | |
| slicer.SetTitle("Aspose") | |
| slicer.SetAlternativeText("Alternate Text") | |
| slicer.SetIsPrintable(false) | |
| slicer.SetIsLocked(false) | |
| // Refresh the slicer. | |
| slicer.Refresh() | |
| // Save the workbook in output XLSX format. | |
| workbook.Save_String(outputDir + "outputChangeSlicerProperties.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiate a new Workbook | |
| wb, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add a comment to A1 cell | |
| comments, _ := ws.GetComments() | |
| commentIndex, _ := comments.Add_String("A1") | |
| comment, _ := comments.Get_Int(commentIndex) | |
| // Set its vertical alignment setting | |
| commentShape, _ := comment.GetCommentShape() | |
| commentShape.SetTextVerticalAlignment(TextAlignmentType_Center) | |
| // Set its horizontal alignment setting | |
| commentShape.SetTextHorizontalAlignment(TextAlignmentType_Right) | |
| // Set the Text Direction - Right-to-Left | |
| commentShape.SetTextDirection(TextDirectionType_RightToLeft) | |
| // Set the Comment note | |
| comment.SetNote("This is my Comment Text. This is a test") | |
| // Save the Excel file | |
| outputPath := outDir + "OutCommentShape.out.xlsx" | |
| wb.Save_String(outputPath) | |
| fmt.Println("Comment shape created and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook object | |
| workbook, _ := NewWorkbook() | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access cells | |
| cells, _ := ws.GetCells() | |
| cell1, _ := cells.Get_String("A1") | |
| cell2, _ := cells.Get_String("B1") | |
| // Set the styles of both cells to Times New Roman | |
| style, _ := cell1.GetStyle() | |
| font, _ := style.GetFont() | |
| font.SetName("Times New Roman") | |
| cell1.SetStyle_Style(style) | |
| cell2.SetStyle_Style(style) | |
| // Put the values inside the cell | |
| cell1.PutValue_String("Hello without Non-Breaking Hyphen") | |
| cell2.PutValue_String("Hello\u2011 with Non-Breaking Hyphen") | |
| // Autofit the columns | |
| ws.AutoFitColumns() | |
| // Save to Pdf without setting PdfSaveOptions.IsFontSubstitutionCharGranularity | |
| workbook.Save_String_SaveFormat(outDir + "SampleOutput_out.pdf", SaveFormat_Pdf) | |
| // Save to Pdf after setting PdfSaveOptions.IsFontSubstitutionCharGranularity to true | |
| opts, _ := NewPdfSaveOptions() | |
| opts.SetIsFontSubstitutionCharGranularity(true) | |
| workbook.Save_String_SaveOptions(outDir + "SampleOutput2_out.pdf", opts.ToSaveOptions()) | |
| fmt.Println("Files saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputPath := srcDir + "Sample1.xlsx" | |
| // Path of output HTML file | |
| outputPath := outDir + "Output.out.html" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputPath) | |
| // Create HTML save options | |
| opts := new(HtmlSaveOptions) | |
| opts.SetLinkTargetType(HtmlLinkTargetType_Self) | |
| // Save the workbook to HTML format | |
| newSaveOptions := opts.ToSaveOptions() | |
| workbook.Save_String_SaveOptions(outputPath, newSaveOptions) | |
| fmt.Printf("File saved: %s\n", outputPath) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Directory source and output paths | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook and load the sample Excel file | |
| workbook, _ := NewWorkbook_String(sourceDir + "SampleChangeTickLabelDirection.xlsx") | |
| // Obtain the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Load the chart from the source worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Set the category axis tick labels direction to Horizontal | |
| categoryAxis, _ := chart.GetCategoryAxis() | |
| tickLabels, _ := categoryAxis.GetTickLabels() | |
| tickLabels.SetDirectionType(ChartTextDirectionType_Horizontal) | |
| // Output the modified workbook to a new file | |
| workbook.Save_String(outDir + "outputChangeChartDataLableDirection.xlsx") | |
| fmt.Println("Chart tick label direction changed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "pivotTable_sample.xlsx" | |
| // Create workbook object from source excel file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access first pivot table | |
| pivotTables, _ := ws.GetPivotTables() | |
| pivotTable, _ := pivotTables.Get_Int(0) | |
| // 1 - Show the pivot table in compact form | |
| pivotTable.ShowInCompactForm() | |
| // Refresh the pivot table | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| // Save the output | |
| workbook.Save_String(outDir + "CompactForm_out.xlsx") | |
| // 2 - Show the pivot table in outline form | |
| pivotTable.ShowInOutlineForm() | |
| // Refresh the pivot table | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| // Save the output | |
| workbook.Save_String(outDir + "OutlineForm_out.xlsx") | |
| // 3 - Show the pivot table in tabular form | |
| pivotTable.ShowInTabularForm() | |
| // Refresh the pivot table | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| // Save the output | |
| workbook.Save_String(outDir + "TabularForm_out.xlsx") | |
| fmt.Println("Pivot table forms saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Workbook object | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Adding sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(60) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(32) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| // Adding a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Accessing the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
| seriesCollection, _ := chart.GetNSeries() | |
| seriesCollection.Add_String_Bool("A1:B3", true) | |
| // Setting the foreground color of the plot area | |
| plotArea, _ := chart.GetPlotArea() | |
| area, _ := plotArea.GetArea() | |
| colorBlue, _ := Color_Blue() | |
| area.SetForegroundColor(colorBlue) | |
| // Setting the foreground color of the chart area | |
| chartArea, _ := chart.GetChartArea() | |
| areaChart, _ := chartArea.GetArea() | |
| colorYellow, _ := Color_Yellow() | |
| areaChart.SetForegroundColor(colorYellow) | |
| // Setting the foreground color of the 1st SeriesCollection area | |
| nSeries, _ := chart.GetNSeries() | |
| series0, _ := nSeries.Get(0) | |
| areaSeries0, _ := series0.GetArea() | |
| colorRed, _ := Color_Red() | |
| areaSeries0.SetForegroundColor(colorRed) | |
| // Setting the foreground color of the area of the 1st SeriesCollection point | |
| points0, _ := series0.GetPoints() | |
| point0, _ := points0.Get(0) | |
| areaPoint0, _ := point0.GetArea() | |
| colorCyan, _ := Color_Cyan() | |
| areaPoint0.SetForegroundColor(colorCyan) | |
| // Filling the area of the 2nd SeriesCollection with a gradient | |
| series1, _ := nSeries.Get(1) | |
| fillFormat1, _ := series1.GetArea() | |
| fillFormat, _ := fillFormat1.GetFillFormat() | |
| colorLime, _ := Color_Lime() | |
| fillFormat.SetOneColorGradient(colorLime, 1, GradientStyleType_Horizontal, 1) | |
| // Applying a dotted line style on the lines of a SeriesCollection | |
| border0, _ := series0.GetBorder() | |
| border0.SetStyle(LineType_Dot) | |
| // Applying a triangular marker style on the data markers of a SeriesCollection | |
| marker0, _ := series0.GetMarker() | |
| marker0.SetMarkerStyle(ChartMarkerType_Triangle) | |
| // Setting the weight of all lines in a SeriesCollection to medium | |
| border1, _ := series1.GetBorder() | |
| border1.SetWeight(WeightType_MediumLine) | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "book1.out.xls") | |
| fmt.Println("Chart created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "book1.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "output.out.xlsx" | |
| // Instantiate the workbook to open the file that contains a chart | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(1) | |
| // Get the first chart in the sheet | |
| charts, _ := worksheet.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Specify the FillFormat's type to Solid Fill of the first series | |
| nSeries, _ := chart.GetNSeries() | |
| series, _ := nSeries.Get(0) // Changed Get_Int to Get | |
| area, _ := series.GetArea() | |
| fillFormat, _ := area.GetFillFormat() | |
| fillFormat.SetFillType(FillType_Solid) | |
| // Get the CellsColor of SolidFill | |
| solidFill, _ := fillFormat.GetSolidFill() | |
| cellsColor, _ := solidFill.GetCellsColor() | |
| // Create a theme in Accent style | |
| themeColor, _ := NewThemeColor(ThemeColorType_Accent6, 0) // Added the missing parameter | |
| cellsColor.SetThemeColor(themeColor) | |
| // Apply the theme to the series | |
| solidFill.SetCellsColor(cellsColor) | |
| // Save the Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Chart theme applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Workbook object | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Adding sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(60) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(32) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| // Adding a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Accessing the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
| seriesCollection, _ := chart.GetNSeries() | |
| seriesCollection.Add_String_Bool("A1:B3", true) | |
| // Setting the foreground color of the plot area | |
| plotArea, _ := chart.GetPlotArea() | |
| area, _ := plotArea.GetArea() | |
| blue, _ := Color_Blue() | |
| area.SetForegroundColor(blue) | |
| // Setting the foreground color of the chart area | |
| chartArea, _ := chart.GetChartArea() | |
| area2, _ := chartArea.GetArea() | |
| yellow, _ := Color_Yellow() | |
| area2.SetForegroundColor(yellow) | |
| // Setting the foreground color of the 1st SeriesCollection area | |
| series, _ := seriesCollection.Get(0) | |
| area3, _ := series.GetArea() | |
| red, _ := Color_Red() | |
| area3.SetForegroundColor(red) | |
| // Setting the foreground color of the area of the 1st SeriesCollection point | |
| points, _ := series.GetPoints() | |
| point, _ := points.Get(0) | |
| area4, _ := point.GetArea() | |
| cyan, _ := Color_Cyan() | |
| area4.SetForegroundColor(cyan) | |
| // Filling the area of the 2nd SeriesCollection with a gradient | |
| series2, _ := seriesCollection.Get(1) | |
| area5, _ := series2.GetArea() | |
| fillFormat, _ := area5.GetFillFormat() | |
| lime, _ := Color_Lime() | |
| fillFormat.SetOneColorGradient(lime, 1, GradientStyleType_Horizontal, 1) | |
| // Setting the title of a chart | |
| title, _ := chart.GetTitle() | |
| title.SetText("Title") | |
| // Setting the font color of the chart title to blue | |
| font, _ := title.GetFont() | |
| fontColor, _ := Color_Blue() | |
| font.SetColor(fontColor) | |
| // Setting the title of category axis of the chart | |
| categoryAxis, _ := chart.GetCategoryAxis() | |
| categoryTitle, _ := categoryAxis.GetTitle() | |
| categoryTitle.SetText("Category") | |
| // Setting the title of value axis of the chart | |
| valueAxis, _ := chart.GetValueAxis() | |
| valueTitle, _ := valueAxis.GetTitle() | |
| valueTitle.SetText("Value") | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "book1.out.xls") | |
| fmt.Println("Chart created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook object | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Workbook object | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Adding sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(60) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(32) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| // Adding a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Accessing the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
| seriesCollection, _ := chart.GetNSeries() | |
| seriesCollection.Add_String_Bool("A1:B3", true) | |
| // Setting the foreground color of the plot area | |
| plotArea, _ := chart.GetPlotArea() | |
| area, _ := plotArea.GetArea() | |
| color_blue, _ := Color_Blue() | |
| area.SetForegroundColor(color_blue) | |
| // Setting the foreground color of the chart area | |
| chartArea, _ := chart.GetChartArea() | |
| areaChart, _ := chartArea.GetArea() | |
| color_yellow, _ := Color_Yellow() | |
| areaChart.SetForegroundColor(color_yellow) | |
| // Setting the foreground color of the 1st SeriesCollection area | |
| nSeries, _ := chart.GetNSeries() | |
| series0, _ := nSeries.Get(0) | |
| areaSeries0, _ := series0.GetArea() | |
| color_red, _ := Color_Red() | |
| areaSeries0.SetForegroundColor(color_red) | |
| // Setting the foreground color of the area of the 1st SeriesCollection point | |
| points0, _ := series0.GetPoints() | |
| point0, _ := points0.Get(0) | |
| areaPoint0, _ := point0.GetArea() | |
| color_cyan, _ := Color_Cyan() | |
| areaPoint0.SetForegroundColor(color_cyan) | |
| // Filling the area of the 2nd SeriesCollection with a gradient | |
| series1, _ := nSeries.Get(1) | |
| areaSeries1, _ := series1.GetArea() | |
| fillFormat, _ := areaSeries1.GetFillFormat() | |
| lime, _ := Color_Lime() | |
| fillFormat.SetOneColorGradient(lime, 1, GradientStyleType_Horizontal, 1) | |
| // Hiding the major gridlines of Category Axis | |
| categoryAxis, _ := chart.GetCategoryAxis() | |
| majorGridLines, _ := categoryAxis.GetMajorGridLines() | |
| majorGridLines.SetIsVisible(false) | |
| // Hiding the major gridlines of Value Axis | |
| valueAxis, _ := chart.GetValueAxis() | |
| majorGridLinesValue, _ := valueAxis.GetMajorGridLines() | |
| majorGridLinesValue.SetIsVisible(false) | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "book1.out.xls") | |
| fmt.Println("Chart created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook object | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Workbook object | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Adding sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(60) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(32) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| // Adding a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Accessing the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
| nSeries, _ := chart.GetNSeries() | |
| nSeries.Add_String_Bool("A1:B3", true) | |
| // Setting the foreground color of the plot area | |
| plotArea, _ := chart.GetPlotArea() | |
| area, _ := plotArea.GetArea() | |
| color_blue, _ := Color_Blue() | |
| area.SetForegroundColor(color_blue) | |
| // Setting the foreground color of the chart area | |
| chartArea, _ := chart.GetChartArea() | |
| area, _ = chartArea.GetArea() | |
| color_yellow, _ := Color_Yellow() | |
| area.SetForegroundColor(color_yellow) | |
| // Setting the foreground color of the 1st SeriesCollection area | |
| series, _ := nSeries.Get(0) | |
| area, _ = series.GetArea() | |
| color_red, _ := Color_Red() | |
| area.SetForegroundColor(color_red) | |
| // Setting the foreground color of the area of the 1st SeriesCollection point | |
| points, _ := series.GetPoints() | |
| point, _ := points.Get(0) | |
| areaPoint, _ := point.GetArea() | |
| color_cyan, _ := Color_Cyan() | |
| areaPoint.SetForegroundColor(color_cyan) | |
| // Filling the area of the 2nd SeriesCollection with a gradient | |
| series, _ = nSeries.Get(1) | |
| areaFillFormat, _ := series.GetArea() | |
| fillFormat, _ := areaFillFormat.GetFillFormat() | |
| limeColor, _ := Color_Lime() | |
| fillFormat.SetOneColorGradient(limeColor, 1, GradientStyleType_Horizontal, 1) | |
| // Setting the color of Category Axis' major gridlines to silver | |
| categoryAxis, _ := chart.GetCategoryAxis() | |
| majorGridLines, _ := categoryAxis.GetMajorGridLines() | |
| color_silver, _ := Color_Silver() | |
| majorGridLines.SetColor(color_silver) | |
| // Setting the color of Value Axis' major gridlines to red | |
| valueAxis, _ := chart.GetValueAxis() | |
| majorGridLines, _ = valueAxis.GetMajorGridLines() | |
| color_red, _ = Color_Red() | |
| majorGridLines.SetColor(color_red) | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "book1.out.xls") | |
| fmt.Println("Chart created and formatted successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Workbook object | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Adding sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(60) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(32) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| // Adding a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Accessing the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
| nSeries, _ := chart.GetNSeries() | |
| nSeries.Add_String_Bool("A1:B3", true) | |
| // Setting the foreground color of the plot area | |
| plotArea, _ := chart.GetPlotArea() | |
| area, _ := plotArea.GetArea() | |
| blue, _ := Color_Blue() | |
| area.SetForegroundColor(blue) | |
| // Setting the foreground color of the chart area | |
| chartArea, _ := chart.GetChartArea() | |
| area, _ = chartArea.GetArea() | |
| yellow, _ := Color_Yellow() | |
| area.SetForegroundColor(yellow) | |
| // Setting the foreground color of the 1st SeriesCollection area | |
| series, _ := nSeries.Get(0) | |
| area, _ = series.GetArea() | |
| red, _ := Color_Red() | |
| area.SetForegroundColor(red) | |
| // Setting the foreground color of the area of the 1st SeriesCollection point | |
| points, _ := series.GetPoints() | |
| point, _ := points.Get(0) | |
| area, _ = point.GetArea() | |
| cyan, _ := Color_Cyan() | |
| area.SetForegroundColor(cyan) | |
| // Filling the area of the 2nd SeriesCollection with a gradient | |
| series, _ = nSeries.Get(1) | |
| area, _ = series.GetArea() | |
| fillFormat, _ := area.GetFillFormat() | |
| lime, _ := Color_Lime() | |
| fillFormat.SetOneColorGradient(lime, 1, GradientStyleType_Horizontal, 1) | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "book1.out.xls") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| type TurkeyChartGlobalizationSettings struct { | |
| ChartGlobalizationSettings | |
| } | |
| func NewTurkeyChartGlobalizationSettings() *TurkeyChartGlobalizationSettings { | |
| return &TurkeyChartGlobalizationSettings{} | |
| } | |
| func (t *TurkeyChartGlobalizationSettings) GetChartTitleName() string { | |
| return "Grafik Başlığı" // Chart Title | |
| } | |
| func (t *TurkeyChartGlobalizationSettings) GetLegendIncreaseName() string { | |
| return "Artış" // Increase | |
| } | |
| func (t *TurkeyChartGlobalizationSettings) GetLegendDecreaseName() string { | |
| return "Düşüş" // Decrease | |
| } | |
| func (t *TurkeyChartGlobalizationSettings) GetLegendTotalName() string { | |
| return "Toplam" // Total | |
| } | |
| func (t *TurkeyChartGlobalizationSettings) GetAxisTitleName() string { | |
| return "Eksen Başlığı" // Axis Title | |
| } | |
| func ChartGlobalizationSettingsTest() { | |
| // Create an instance of existing Workbook | |
| pathName := "input.xlsx" | |
| workbook, _ := NewWorkbook_String(pathName) | |
| // Set custom chartGlobalizationSettings, here is TurkeyChartGlobalizationSettings | |
| globalizationSettings := NewTurkeyChartGlobalizationSettings() | |
| settings, _ := workbook.GetSettings() | |
| globalization, _ := settings.GetGlobalizationSettings() | |
| globalization.SetChartSettings(&globalizationSettings.ChartGlobalizationSettings) | |
| // Get the worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Load the chart from source worksheet | |
| chartCollection, _ := worksheet.GetCharts() | |
| chart, _ := chartCollection.Get_Int(0) | |
| // Chart Calculate | |
| chart.Calculate() | |
| // Get the chart title | |
| title, _ := chart.GetTitle() | |
| titleText, _ := title.GetText() | |
| // Output the name of the Chart title | |
| fmt.Printf("\nWorkbook chart title: %s\n", titleText) | |
| // Get the legend labels | |
| legend, _ := chart.GetLegend() | |
| legendEntriesLabels, _ := legend.GetLegendLabels() | |
| // Output the name of the Legend | |
| for i := 0; i < len(legendEntriesLabels); i++ { | |
| fmt.Printf("\nWorkbook chart legend: %s\n", legendEntriesLabels[i]) | |
| } | |
| // Output the name of the Axis title | |
| categoryAxis, _ := chart.GetCategoryAxis() | |
| categoryAxisTitle, _ := categoryAxis.GetTitle() | |
| categoryAxisTitleText, _ := categoryAxisTitle.GetText() | |
| fmt.Printf("\nWorkbook category axis title: %s\n", categoryAxisTitleText) | |
| } | |
| func main() { | |
| ChartGlobalizationSettingsTest() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Create an instance of Workbook class | |
| book, _ := NewWorkbook() | |
| // Setting this property to true will make Aspose.Cells to throw exception | |
| // when invalid custom number format is assigned to Style.Custom property | |
| settings, _ := book.GetSettings() | |
| settings.SetCheckCustomNumberFormat(true) | |
| // Access first worksheet | |
| wss, _ := book.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Access cell A1 and put some number to it | |
| cells, _ := sheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(2347) | |
| // Access cell's style and set its Style.Custom property | |
| style, _ := cell.GetStyle() | |
| // This line will throw exception if Workbook.Settings.CheckCustomNumberFormat is set to true | |
| style.SetCustom_String("ggg @ fff") // Fixed function call with correct parameter type | |
| fmt.Println("Custom number format set.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Load the workbook from an existing Excel file with VBA project | |
| workbook, _ := NewWorkbook_String(srcDir + "sampleVBAProjectSigned.xlsm") | |
| // Check if the VBA Code Project is valid signed | |
| vbaProject, _ := workbook.GetVbaProject() | |
| isValidSigned, _ := vbaProject.IsValidSigned() | |
| fmt.Printf("Is VBA Code Project Valid Signed: %v\n", isValidSigned) | |
| // Modify the VBA Code | |
| modules, _ := vbaProject.GetModules() | |
| module, _ := modules.Get_Int(1) | |
| code, _ := module.GetCodes() | |
| code = "Welcome to Aspose.Cells" // Directly setting new code here | |
| _ = module.SetCodes(code) | |
| // Save the workbook | |
| _ = workbook.Save_String(srcDir + "output_out.xlsm") | |
| // Reload the workbook | |
| workbook, _ = NewWorkbook_String(srcDir + "output_out.xlsm") | |
| // Now the signature is invalid | |
| isValidSigned, _ = vbaProject.IsValidSigned() | |
| fmt.Printf("Is VBA Code Project Valid Signed: %v\n", isValidSigned) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "sampleVBAProjectSigned.xlsm" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Check if the VBA code project is signed | |
| vbaProject, _ := workbook.GetVbaProject() | |
| isSigned, _ := vbaProject.IsSigned() | |
| fmt.Println("Is VBA Code Project Signed:", isSigned) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input excel file | |
| sampleFilePath := srcDir + "Sample1.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(sampleFilePath) | |
| // Check if the VBA project is signed | |
| vbaProject, _ := workbook.GetVbaProject() | |
| isSigned, _ := vbaProject.IsSigned() | |
| fmt.Printf("VBA Project is Signed: %v\n", isSigned) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "sampleCheckifVBAProjectisProtected.xlsm" | |
| // Load your source Excel file | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access the VBA project of the workbook | |
| vbaProject, _ := wb.GetVbaProject() | |
| // Check if "Lock project for viewing" is true or not | |
| isLockedForViewing, _ := vbaProject.GetIslockedForViewing() | |
| fmt.Println("Is VBA Project Locked for Viewing:", isLockedForViewing) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "sampleBook.xlsx" | |
| // Specify password to open inside the load options | |
| opts, _ := NewLoadOptions() // Modified to get both return values | |
| opts.SetPassword("1234") | |
| // Open the source Excel file with load options | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Check if the workbook is write protected | |
| writeProtection, _ := workbook.GetSettings() // Modified to handle multiple returns | |
| ret, _ := writeProtection.IsProtected() // Use the correct method to check if the workbook is write protected | |
| fmt.Printf("Is the workbook write protected: %v\n", ret) | |
| // To check password protection, you need to handle it differently. | |
| // Assuming you already know if it requires a password | |
| fmt.Println("To check specific passwords, you would normally need to try opening with those passwords, but this API does not offer direct password validation.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| type ChartChineseSettings struct { | |
| *ChartGlobalizationSettings | |
| } | |
| func NewChartChineseSettings() *ChartChineseSettings { | |
| return &ChartChineseSettings{&ChartGlobalizationSettings{}} | |
| } | |
| func (c *ChartChineseSettings) GetAxisTitleName() string { | |
| return "\u5750\u6807\u8F74\u6807\u9898" | |
| } | |
| func (c *ChartChineseSettings) GetAxisUnitName(type_ DisplayUnitType) string { | |
| switch type_ { | |
| case DisplayUnitType_None: | |
| return "" | |
| case DisplayUnitType_Hundreds: | |
| return "\u767E" | |
| case DisplayUnitType_Thousands: | |
| return "\u5343" | |
| case DisplayUnitType_HundredMillions: // removed DisplayUnitType_TenMillions to fix duplicate case | |
| return "\u4EBF" | |
| case DisplayUnitType_Millions: | |
| return "\u767E\u4E07" | |
| case DisplayUnitType_Billions: | |
| return "\u5341\u4EBF" | |
| case DisplayUnitType_Trillions: | |
| return "\u5146" | |
| default: | |
| return "" | |
| } | |
| } | |
| func (c *ChartChineseSettings) GetChartTitleName() string { | |
| return "\u56FE\u8868\u6807\u9898" | |
| } | |
| func (c *ChartChineseSettings) GetLegendDecreaseName() string { | |
| return "\u51CF\u5C11" | |
| } | |
| func (c *ChartChineseSettings) GetLegendIncreaseName() string { | |
| return "\u589E\u52A0" | |
| } | |
| func (c *ChartChineseSettings) GetLegendTotalName() string { | |
| return "\u6C47\u603B" | |
| } | |
| func (c *ChartChineseSettings) GetOtherName() string { | |
| return "\u5176\u4ED6" | |
| } | |
| func (c *ChartChineseSettings) GetSeriesName() string { | |
| return "\u7CFB\u5217" | |
| } | |
| // Config Chinese Setting For Chart | |
| // In this step, you will use the class "ChartChineseSettings" you defined in the previous step. | |
| func main() { | |
| wb, _ := NewWorkbook_String("Chinese.xls") | |
| chartChineseSettings := NewChartChineseSettings() | |
| settings, _ := wb.GetSettings() | |
| globalizationSettings, _ := settings.GetGlobalizationSettings() | |
| globalizationSettings.SetChartSettings(chartChineseSettings.ChartGlobalizationSettings) // fixed type error | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| charts, _ := ws.GetCharts() | |
| chart0, _ := charts.Get_Int(0) // changed from Get to Get_Int | |
| chart0.ToImage_String("Output.png") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Check if Orchid color is in the palette | |
| colorOrchid, _ := Color_Orchid() | |
| isOrchidInPalette, _ := workbook.IsColorInPalette(colorOrchid) | |
| fmt.Println("Is Orchid in palette? ", isOrchidInPalette) | |
| // Add Orchid color to the palette at index 55 | |
| workbook.ChangePalette(colorOrchid, 55) | |
| // Verify if Orchid is now in the palette | |
| isOrchidInPaletteNow, _ := workbook.IsColorInPalette(colorOrchid) | |
| fmt.Println("Is Orchid in palette now? ", isOrchidInPaletteNow) | |
| // Add a new worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| i, _ := wss.Add() | |
| // Get the reference to the newly added worksheet | |
| worksheet, _ := wss.Get_Int(i) | |
| // Access cell A1 | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Set value in cell A1 | |
| cell.PutValue_String("Hello Aspose!") | |
| // Create a new style | |
| styleObject, _ := workbook.CreateStyle() | |
| // Set the custom color (Orchid) to the font | |
| font, _ := styleObject.GetFont() | |
| font.SetColor(colorOrchid) | |
| // Apply the style to the cell | |
| cell.SetStyle_Style(styleObject) | |
| // Save the workbook | |
| workbook.Save_String("out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-G | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input excel file | |
| filePath := srcDir + "SampleInput.xlsx" | |
| // Create workbook from the input file | |
| workbook, _ := NewWorkbook_String(filePath) | |
| // Create a destination workbook | |
| destWorkbook, _ := NewWorkbook() | |
| // Get the first worksheet of the destination workbook | |
| wss, _ := destWorkbook.GetWorksheets() | |
| destSheet, _ := wss.Get_Int(0) | |
| // Variable to maintain total row count during copy | |
| totalRowCount := int32(0) | |
| // Iterate through each worksheet in the source workbook | |
| worksheetCollection, _ := workbook.GetWorksheets() | |
| worksheetCount, _ := worksheetCollection.GetCount() | |
| for i := int32(0); i < worksheetCount; i++ { | |
| sourceSheet, _ := worksheetCollection.Get_Int(i) | |
| // Get the display range of the source sheet | |
| sourceCells, _ := sourceSheet.GetCells() | |
| sourceRange, _ := sourceCells.GetMaxDisplayRange() | |
| // Create a range in the destination sheet according to the source range | |
| firstRow, _ := sourceRange.GetFirstRow() | |
| firstColumn, _ := sourceRange.GetFirstColumn() | |
| rowCount, _ := sourceRange.GetRowCount() | |
| columnCount, _ := sourceRange.GetColumnCount() | |
| destCells, _ := destSheet.GetCells() | |
| destRange, _ := destCells.CreateRange_Int_Int_Int_Int(firstRow+totalRowCount, firstColumn, rowCount, columnCount) | |
| // Copy data from source range to destination range | |
| destRange.CopyData(sourceRange) // Use the appropriate method to copy data | |
| // Update the total row count for the next iteration | |
| totalRowCount += rowCount | |
| } | |
| // Save the destination workbook to the output path | |
| outputFilePath := srcDir + "Output.out.xlsx" | |
| _ = destWorkbook.Save_String(outputFilePath) | |
| fmt.Println("Workbook processed and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Workbook object | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Accessing the comments collection | |
| comments, _ := worksheet.GetComments() | |
| // Adding a comment to "F5" cell | |
| commentIndex, _ := comments.Add_String("F5") | |
| // Accessing the newly added comment | |
| comment, _ := comments.Get_Int(commentIndex) | |
| // Setting the comment note | |
| comment.SetNote("Hello Aspose!") | |
| // Setting the font size of a comment to 14 | |
| font, _ := comment.GetFont() | |
| font.SetSize(14) | |
| // Setting the font of a comment to bold | |
| font.SetIsBold(true) | |
| // Setting the height of the comment to 10 | |
| comment.SetHeightCM(10) | |
| // Setting the width of the comment to 2 | |
| comment.SetWidthCM(2) | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "book1.out.xls") | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "../Data/01_SourceDirectory/" | |
| outDir := "../Data/02_OutputDirectory/" | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| comments, _ := ws.GetComments() | |
| commentIndex, _ := comments.Add_Int_Int(0, 0) | |
| comment, _ := comments.Get_Int(commentIndex) | |
| comment.SetNote("First note.") | |
| commentFont, _ := comment.GetFont() | |
| commentFont.SetName("Times New Roman") | |
| imagePath := srcDir + "logo.jpg" | |
| imageData, _ := ioutil.ReadFile(imagePath) | |
| shape, _ := comment.GetCommentShape() | |
| fill, _ := shape.GetFill() | |
| fill.SetImageData(imageData) | |
| outputPath := outDir + "book1.out.xlsx" | |
| workbook.Save_String_SaveFormat(outputPath, SaveFormat_Xlsx) | |
| fmt.Println("Workbook with image comment created successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Add a new worksheet to the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Get the reference of the newly added worksheet | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Add a comment to cell "F5" | |
| commentsCollection, _ := worksheet.GetComments() | |
| commentIndex, _ := commentsCollection.Add_String("F5") | |
| // Access the newly added comment | |
| comment, _ := commentsCollection.Get_Int(commentIndex) | |
| // Set the comment note | |
| comment.SetNote("Hello Aspose!") | |
| // Save the Excel file | |
| outputPath := outDir + "book1.out.xls" | |
| workbook.Save_String(outputPath) | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| filePath := srcDir + "Book1.xlsx" | |
| // Instantiating a Workbook object | |
| workbook, _ := NewWorkbook_String(filePath) | |
| wss, _ := workbook.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Adds an empty conditional formatting | |
| conditionalFormattings, _ := sheet.GetConditionalFormattings() | |
| index, _ := conditionalFormattings.Add() | |
| fcs, _ := conditionalFormattings.Get(index) | |
| // Sets the conditional format range. | |
| ca, _ := CellArea_CreateCellArea_Int_Int_Int_Int(0, 0, 0, 0) | |
| fcs.AddArea(ca) | |
| ca, _ = CellArea_CreateCellArea_Int_Int_Int_Int(1, 1, 1, 1) | |
| fcs.AddArea(ca) | |
| // Adds condition. | |
| conditionIndex, _ := fcs.AddCondition_FormatConditionType_OperatorType_String_String(FormatConditionType_CellValue, OperatorType_Between, "=A2", "100") | |
| // Sets the background color. | |
| fc, _ := fcs.Get(conditionIndex) | |
| style, _ := fc.GetStyle() | |
| colorRed, _ := Color_Red() | |
| style.SetBackgroundColor(colorRed) | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "output.xls") | |
| fmt.Println("Conditional formatting applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Add a new worksheet to the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| i, _ := wss.Add() | |
| // Get the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(i) | |
| // Access the "A1" cell from the worksheet | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Add some value to the "A1" cell | |
| cell.PutValue_String("Hello Aspose!") | |
| // Get the style of the cell | |
| style, _ := cell.GetStyle() | |
| // Set the font weight to bold | |
| font, _ := style.GetFont() | |
| font.SetIsBold(true) | |
| // Apply the style to the cell | |
| cell.SetStyle_Style(style) | |
| // Save the Excel file | |
| workbook.Save_String_SaveFormat(outDir + "book1.out.xls", SaveFormat_Excel97To2003) | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Add an empty conditional formatting | |
| conditionalFormattings, _ := sheet.GetConditionalFormattings() | |
| index, _ := conditionalFormattings.Add() | |
| fcs, _ := conditionalFormattings.Get(index) | |
| // Set the conditional format range | |
| ca, _ := CellArea_CreateCellArea_Int_Int_Int_Int(0, 0, 5, 3) | |
| fcs.AddArea(ca) | |
| // Add condition | |
| conditionIndex, _ := fcs.AddCondition_FormatConditionType_OperatorType_String_String(FormatConditionType_CellValue, OperatorType_Between, "50", "100") | |
| // Set the background color | |
| fc, _ := fcs.Get(conditionIndex) | |
| borders, _ := fc.GetStyle() | |
| borderCollection, _ := borders.GetBorders() | |
| leftBorder, _ := borderCollection.Get(BorderType_LeftBorder) | |
| leftBorder.SetLineStyle(CellBorderType_Dashed) | |
| rightBorder, _ := borderCollection.Get(BorderType_RightBorder) | |
| rightBorder.SetLineStyle(CellBorderType_Dashed) | |
| topBorder, _ := borderCollection.Get(BorderType_TopBorder) | |
| topBorder.SetLineStyle(CellBorderType_Dashed) | |
| bottomBorder, _ := borderCollection.Get(BorderType_BottomBorder) | |
| bottomBorder.SetLineStyle(CellBorderType_Dashed) | |
| color, _ := NewColor() | |
| leftBorder.SetColor(color) | |
| rightBorder.SetColor(color) | |
| topBorder.SetColor(color) | |
| bottomBorder.SetColor(color) | |
| // Save the workbook | |
| workbook.Save_String(outDir + "output.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Adds an empty conditional formatting | |
| conditionings, _ := ws.GetConditionalFormattings() | |
| index, _ := conditionings.Add() | |
| fcs, _ := conditionings.Get(index) | |
| // Sets the conditional format range | |
| ca, _ := CellArea_CreateCellArea_Int_Int_Int_Int(0, 0, 5, 3) // Fixed method to create the cell area | |
| fcs.AddArea(ca) | |
| // Adds condition | |
| conditionIndex, _ := fcs.AddCondition_FormatConditionType_OperatorType_String_String(FormatConditionType_CellValue, OperatorType_Between, "50", "100") // Fixed method to add condition | |
| fc, _ := fcs.Get(conditionIndex) // Fixed method to get the format condition | |
| style, _ := fc.GetStyle() | |
| style.SetPattern(BackgroundType_ReverseDiagonalStripe) | |
| yellow, _ := NewColor() | |
| style.SetForegroundColor(yellow) | |
| cyan, _ := NewColor() | |
| style.SetBackgroundColor(cyan) | |
| // Save the workbook | |
| workbook.Save_String(outDir + "output.xlsx") | |
| fmt.Println("Conditional formatting applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "Book1.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "output.xls" | |
| // Open the Excel file | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet in the Excel file | |
| wss, _ := wb.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| var totalRowCount int32 = 0 | |
| // Iterate through all worksheets in the workbook | |
| count, _ := wss.GetCount() | |
| for i := int32(0); i < count; i++ { | |
| sourceSheet, _ := wss.Get_Int(i) | |
| // Get the maximum display range of the source sheet | |
| sourceCells, _ := sourceSheet.GetCells() | |
| sourceRange, _ := sourceCells.GetMaxDisplayRange() | |
| // Create a destination range in the first worksheet | |
| firstRow, _ := sourceRange.GetFirstRow() | |
| firstCol, _ := sourceRange.GetFirstColumn() | |
| rowCount, _ := sourceRange.GetRowCount() | |
| colCount, _ := sourceRange.GetColumnCount() | |
| destCells, _ := worksheet.GetCells() | |
| destRange, _ := destCells.CreateRange_Int_Int_Int_Int(firstRow+totalRowCount, firstCol, rowCount, colCount) | |
| // Copy data from source range to destination range | |
| destRange.CopyData(sourceRange) | |
| // Update the total row count | |
| totalRowCount += rowCount | |
| } | |
| // Save the modified Excel file | |
| wb.Save_String(outputFilePath) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Substituting the Arial font with Times New Roman & Calibri | |
| substituteFonts := []string{"Times New Roman", "Calibri"} | |
| FontConfigs_SetFontSubstitutes("Arial", substituteFonts) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func GetDataFromFile(file string) ([]byte, error) { | |
| // open a file | |
| fileStream, err := ioutil.ReadFile(file) | |
| if err != nil { | |
| fmt.Println("Failed to open the file.") | |
| return nil, err | |
| } | |
| // Read file contents into byte array | |
| data := make([]byte, len(fileStream)) | |
| copy(data, fileStream) | |
| return data, nil | |
| } | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| fontFolder1 := srcDir + "Arial" | |
| fontFolder2 := srcDir + "Calibri" | |
| fontFile := srcDir + "arial.ttf" | |
| FontConfigs_SetFontFolder(fontFolder1, true) | |
| fontFolders := []string{fontFolder1, fontFolder2} | |
| FontConfigs_SetFontFolders(fontFolders, true) | |
| sourceFolder, _ := NewFolderFontSource_String_Bool(fontFolder1, true) | |
| sourceFile, _ := NewFileFontSource_String(fontFile) | |
| fontData, _ := GetDataFromFile(fontFile) | |
| sourceMemory, _ := NewMemoryFontSource_Stream(fontData) | |
| fontSources := []FontSourceBase{ | |
| FontSourceBase(*sourceFolder), | |
| FontSourceBase(*sourceFile), | |
| FontSourceBase(*sourceMemory), | |
| } | |
| FontConfigs_SetFontSources(fontSources) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "Book.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "output.xlsx" | |
| // Create workbook from source excel file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet of the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the first pivot table of the worksheet | |
| pivotTables, _ := worksheet.GetPivotTables() | |
| pivotTable, _ := pivotTables.Get_Int(0) | |
| // Apply Average consolidation function to first data field | |
| dataFields, _ := pivotTable.GetDataFields() | |
| dataField, _ := dataFields.Get_Int(0) | |
| dataField.SetFunction(ConsolidationFunction_Average) | |
| // Apply DistinctCount consolidation function to second data field | |
| dataField2, _ := dataFields.Get_Int(1) | |
| dataField2.SetFunction(ConsolidationFunction_DistinctCount) | |
| // Calculate the data to make changes affect | |
| pivotTable.CalculateData() | |
| // Saving the Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Pivot table updated and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Open the existing excel file which contains the column chart. | |
| inputFilePath := srcDir + "ColumnChart.xlsx" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Get the designer chart (first chart) in the first worksheet of the workbook. | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| charts, _ := worksheet.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Convert the chart to an image file. | |
| outputImagePath := srcDir + "ColumnChart.out.jpeg" | |
| chart.ToImage_String_ImageType(outputImagePath, ImageType_Jpeg) | |
| fmt.Println("Chart converted to image successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Open the existing excel file which contains the pie chart. | |
| workbook, _ := NewWorkbook_String(srcDir + "PieChart.xlsx") | |
| // Get the designer chart (first chart) in the first worksheet of the workbook. | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| charts, _ := ws.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Convert the chart to an image file. | |
| chart.ToImage_String_ImageType(srcDir + "PieChart.out.emf", ImageType_Emf) | |
| fmt.Println("Chart converted to image successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Load CSV file | |
| workbook, _ := NewWorkbook_String(srcDir + "SampleCsv.csv") | |
| // Get the last cell in the worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| lastCell, _ := cells.GetLastCell() | |
| // Set JsonSaveOptions | |
| jsonSaveOptions, _ := NewJsonSaveOptions() | |
| // Create a range from the first cell to the last cell | |
| lastRow, _ := lastCell.GetRow() | |
| lastColumn, _ := lastCell.GetColumn() | |
| rangeObj, _ := cells.CreateRange_Int_Int_Int_Int(0, 0, lastRow+1, lastColumn+1) | |
| // Export the range to JSON | |
| data, _ := JsonUtility_ExportRangeToJson(rangeObj, jsonSaveOptions) | |
| // Print JSON | |
| fmt.Println(data) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create load options for XLSX format | |
| options, _ := NewLoadOptions() | |
| // Set culture info to Japanese | |
| options.SetLanguageCode(CountryCode_Japan) | |
| // Load the workbook with Japanese dates | |
| workbook, _ := NewWorkbook_String(srcDir + "JapaneseDates.xlsx") | |
| // Save the workbook as PDF | |
| workbook.Save_String(outDir + "JapaneseDates.pdf") | |
| fmt.Println("Workbook saved successfully as PDF with Japanese dates!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create workbook object | |
| wb, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access cell B5 and add some message inside it | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("B5") | |
| cell.PutValue_String("This PDF format is compatible with PDFA-1a.") | |
| // Create pdf save options and set its compliance to PDFA-1a | |
| opts, _ := NewPdfSaveOptions() | |
| opts.SetCompliance(PdfCompliance_PdfA1a) | |
| // Save the output pdf | |
| newOpts := opts.ToSaveOptions() | |
| wb.Save_String_SaveOptions("..\\Data\\02_OutputDirectory\\outputCompliancePdfA1a.pdf", newOpts) | |
| fmt.Println("PDF created successfully with PDFA-1a compliance!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Load the Excel file | |
| workbook, _ := NewWorkbook_String("input.xlsx") | |
| // Create an instance of ImageOrPrintOptions | |
| options, _ := NewImageOrPrintOptions() | |
| options.SetHorizontalResolution(300) // Set horizontal resolution to 300 DPI | |
| options.SetVerticalResolution(300) // Set vertical resolution to 300 DPI | |
| options.SetImageType(ImageType_Png) // Set the image type | |
| // Get the worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Create a SheetRender instance | |
| render, _ := NewSheetRender(sheet, options) | |
| // Generate and save the image | |
| render.ToImage_Int_String(0, "output.png") | |
| fmt.Println("Image generated successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open the template file | |
| workbook, _ := NewWorkbook_String(sourceDir + "AddTooltipToHtmlSample.xlsx") | |
| // Setup HTML save options | |
| options := new(HtmlSaveOptions) | |
| options.SetAddTooltipText(true) // Enable tooltip text in output | |
| // Save as HTML | |
| newOptions := options.ToSaveOptions() | |
| workbook.Save_String_SaveOptions(outputDir + "AddTooltipToHtmlSample_out.html", newOptions) | |
| fmt.Println("Workbook saved with tooltip text added!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Golang | |
| // Create an options of saving the file. | |
| options, _ := NewJsonSaveOptions() | |
| // Set the exporting range. | |
| cellArea, _ := CellArea_CreateCellArea_String_String("B1", "C4") | |
| options.SetExportArea(cellArea) | |
| // Load your source workbook | |
| workbook, _ := NewWorkbook_String("sample.xlsx") | |
| // Convert the workbook to json file. | |
| workbook.Save_String_SaveOptions("sample_out.json", options.ToSaveOptions()) | |
| fmt.Println("Workbook successfully converted to JSON!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Load your source workbook | |
| inputFilePath := "sample.xlsx" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Convert the workbook to JSON file. | |
| outputFilePath := "sample_out.json" | |
| saveOptions, _ := NewJsonSaveOptions() | |
| workbook.Save_String_SaveOptions(outputFilePath, saveOptions.ToSaveOptions()) | |
| fmt.Println("Workbook converted to JSON successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Load the HTML file into a workbook | |
| inputFilePath := "sample.html" | |
| book, _ := NewWorkbook_String(inputFilePath) | |
| // Save the workbook as PDF | |
| outputFilePath := "out.pdf" | |
| book.Save_String(outputFilePath) | |
| fmt.Println("HTML file converted to PDF successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "SampleChartBook.xlsx" | |
| // Create workbook object from source file | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access first chart inside the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Set image or print options | |
| opts, _ := NewImageOrPrintOptions() | |
| // Save the chart to SVG format | |
| chart.ToImage_String_ImageOrPrintOptions(outDir+"Image_out.svg", opts) | |
| fmt.Println("Chart saved to SVG format successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func intToU16String(value int32) string { | |
| var result string | |
| if value == 0 { | |
| return "0" | |
| } | |
| for value > 0 { | |
| result = string('0'+(value%10)) + result | |
| value /= 10 | |
| } | |
| return result | |
| } | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| wb, _ := NewWorkbook_String(srcDir + "sampleConvertWorksheetToImageByPage.xlsx") | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| options := new(ImageOrPrintOptions) | |
| options.SetHorizontalResolution(200) | |
| options.SetVerticalResolution(200) | |
| options.SetImageType(ImageType_Tiff) | |
| sr, _ := NewSheetRender(ws, options) | |
| pageCount, _ := sr.GetPageCount() | |
| for j := int32(0); j < pageCount; j++ { | |
| pageNum := intToU16String(j + 1) | |
| fileName := outDir + "outputConvertWorksheetToImageByPage_" + pageNum + ".tif" | |
| sr.ToImage_Int_String(j, fileName) | |
| } | |
| fmt.Println("Worksheet converted to images by page successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func convert_u16_to_string(u16str string) string { | |
| return u16str | |
| } | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| wb, _ := NewWorkbook_String(srcDir + "sampleConvertWorksheettoImageFile.xlsx") | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| imgOptions, _ := NewImageOrPrintOptions() | |
| imgOptions.SetOnePagePerSheet(true) | |
| imgOptions.SetImageType(ImageType_Jpeg) | |
| sr, _ := NewSheetRender(ws, imgOptions) | |
| sr.ToImage_Int_String(0, outDir+"outputConvertWorksheettoImageFile.jpg") | |
| fmt.Println("Worksheet converted to image successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| inputPath := srcDir + "sampleSpecificPagesToImages.xlsx" | |
| workbook, _ := NewWorkbook_String(inputPath) | |
| worksheets, _ := workbook.GetWorksheets() | |
| ws, _ := worksheets.Get_Int(0) | |
| imgOptions, _ := NewImageOrPrintOptions() | |
| imgOptions.SetImageType(ImageType_Jpeg) | |
| sr, _ := NewSheetRender(ws, imgOptions) | |
| pageIndex := int32(3) | |
| imageData, _ := sr.ToImage_Int(pageIndex) | |
| pageNumStr := fmt.Sprintf("%d", pageIndex+1) | |
| outputPath := outDir + "outputSpecificPagesToImage_" + pageNumStr + ".jpg" | |
| outputFile, _ := os.Create(outputPath) | |
| defer outputFile.Close() | |
| _, _ = outputFile.Write(imageData) | |
| fmt.Printf("Page rendered successfully to: %s\n", outputPath) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load the workbook | |
| wb, _ := NewWorkbook_String(srcDir + "sampleUseWorkbookRenderForImageConversion.xlsx") | |
| // Set image options | |
| opts, _ := NewImageOrPrintOptions() | |
| opts.SetImageType(ImageType_Tiff) | |
| // Render workbook to image | |
| wr, _ := NewWorkbookRender(wb, opts) | |
| wr.ToImage_String(outDir + "outputUseWorkbookRenderForImageConversion.tiff") | |
| fmt.Println("Workbook rendered to image successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| wb, _ := NewWorkbook_String(srcDir + "sampleWorksheetToAnImage.xlsx") | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| options, _ := NewImageOrPrintOptions() | |
| options.SetHorizontalResolution(300) | |
| options.SetVerticalResolution(300) | |
| options.SetTiffCompression(TiffCompression_CompressionLZW) | |
| options.SetImageType(ImageType_Tiff) | |
| options.SetPrintingPage(PrintingPageType_Default) | |
| sr, _ := NewSheetRender(ws, options) | |
| pageIndex := int32(3) | |
| pageNumber := pageIndex + 1 | |
| pageNumberStr := fmt.Sprintf("%d", pageNumber) | |
| outputPath := outDir + "outputWorksheetToAnImage_" + pageNumberStr + ".tiff" | |
| sr.ToImage_Int_String(pageIndex, outputPath) | |
| fmt.Println("Worksheet converted to image successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| jsonFilePath := srcDir + "SampleJson.json" | |
| jsonData, err := ioutil.ReadFile(jsonFilePath) | |
| if err != nil { | |
| fmt.Println("Failed to open JSON file:", jsonFilePath) | |
| return | |
| } | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| importOptions := &JsonLayoutOptions{} | |
| importOptions.SetConvertNumericOrDate(true) | |
| importOptions.SetArrayAsTable(true) | |
| importOptions.SetIgnoreTitle(true) | |
| JsonUtility_ImportData(string(jsonData), cells, 0, 0, importOptions) | |
| outputFilePath := outDir + "SampleJson_out.csv" | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("JSON data imported and workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Create an options for loading the file. | |
| options := new(JsonLoadOptions) | |
| // Indicates whether importing each attribute of JsonObject object as one worksheet when all child nodes are array nodes. | |
| options.SetMultipleWorksheets(true) | |
| // Create a workbook from the JSON file with the specified options. | |
| inputFilePath := "sample.json" | |
| book, _ := NewWorkbook_String(inputFilePath) | |
| // Save file to xlsx format. | |
| outputFilePath := "sample_out.xlsx" | |
| err := book.Save_String(outputFilePath) | |
| if err != nil { | |
| fmt.Println("Error saving workbook:", err) | |
| return | |
| } | |
| fmt.Println("File converted successfully to xlsx format!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // JSON input string | |
| inputJson := `[{"BEFORE": "before cell", "TEST": "asd1", "AFTER": "after cell"}, {"BEFORE": "before cell", "TEST": "asd2", "AFTER": "after cell"}, {"BEFORE": "before cell", "TEST": "asd3", "AFTER": "after cell"}, {"BEFORE": "before cell", "TEST": "asd4", "AFTER": "after cell"}]` | |
| sheetName := "Sheet1" | |
| row := int32(3) // Convert row to int32 | |
| column := int32(2) // Convert column to int32 | |
| // Create a Workbook object | |
| book, _ := NewWorkbook() | |
| worksheets, _ := book.GetWorksheets() | |
| worksheet, _ := worksheets.Get_String(sheetName) | |
| // Set JsonLayoutOptions to treat Arrays as Table | |
| jsonLayoutOptions, _ := NewJsonLayoutOptions() | |
| jsonLayoutOptions.SetArrayAsTable(true) | |
| // Import JSON data into the worksheet | |
| cells, _ := worksheet.GetCells() | |
| JsonUtility_ImportData(inputJson, cells, row, column, jsonLayoutOptions) | |
| // Save the file to xlsx format | |
| book.Save_String("out.xlsx") | |
| fmt.Println("Data imported successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Create a Workbook object from a JSON file | |
| workbook, _ := NewWorkbook_String("sample.json") | |
| // Save the file to xlsx format | |
| workbook.Save_String("sample_out.xlsx") | |
| fmt.Println("File saved successfully in xlsx format!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "sample.xlsb" | |
| // Create workbook from the input file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Save Workbook to XLSM format | |
| options, _ := NewOoxmlSaveOptions() | |
| outputFilePath := outDir + "output_out.xlsm" | |
| _ = workbook.Save_String_SaveOptions(outputFilePath, options.ToSaveOptions()) | |
| fmt.Println("Workbook saved successfully in XLSM format!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C++ | |
| // Source directory path | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open an existing file that contains a table/list object in it | |
| inputFilePath := sourceDir + "SampleTable.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Save the file in ODS format | |
| wb.Save_String(outputDir + "ConvertTableToOds_out.ods") | |
| fmt.Println("Conversion to ODS completed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("sample.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| listObjects, _ := worksheet.GetListObjects() | |
| listObject, _ := listObjects.Get_Int(0) | |
| listObject.ConvertToRange() | |
| workbook.Save_String("ConvertTableToRange_out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiate workbook object with an Excel file | |
| inputFilePath := srcDir + "SampleBook.xlsx" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Iterate through all worksheets and convert string values to numeric | |
| wss, _ := workbook.GetWorksheets() | |
| count, _ := wss.GetCount() | |
| for i := int32(0); i < count; i++ { | |
| ws, _ := wss.Get_Int(i) | |
| cells, _ := ws.GetCells() | |
| cells.ConvertStringToNumericValue() | |
| } | |
| // Save the Excel file | |
| outputFilePath := outDir + "output_out.xlsx" | |
| workbook.Save_String_SaveOptions(outputFilePath, nil) | |
| fmt.Println("Conversion completed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook | |
| wb, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add people name in column A. Fast name and Last name are separated by space. | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("John Teal") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Peter Graham") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Brady Cortez") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Mack Nick") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Hsu Lee") | |
| // Create text load options with space as separator | |
| opts, _ := NewTxtLoadOptions() | |
| // Split the column A into two columns using TextToColumns() method | |
| // Now column A will have first name and column B will have second name | |
| cells.TextToColumns(0, 0, 5, opts) | |
| // Save the workbook in xlsx format | |
| wb.Save_String(outDir + "outputTextToColumns.xlsx") | |
| fmt.Println("Text to columns conversion completed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Load the sample smart art shape - Excel file | |
| inputFilePath := "sampleSmartArtShape_GetResultOfSmartArt.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access first shape | |
| shapes, _ := ws.GetShapes() | |
| sh, _ := shapes.Get_Int(0) | |
| // Determine if shape is smart art | |
| isSmartArt, _ := sh.IsSmartArt() | |
| fmt.Println("Is Smart Art Shape:", isSmartArt) | |
| // Determine if shape is group shape | |
| isGroup, _ := sh.IsGroup() | |
| fmt.Println("Is Group Shape:", isGroup) | |
| // Convert smart art shape into group shape | |
| resultOfSmartArt, _ := sh.GetResultOfSmartArt() | |
| isGroupResult, _ := resultOfSmartArt.IsGroup() | |
| fmt.Println("Is Group Shape (after conversion):", isGroupResult) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "os" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("67338402.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| imageOrPrintOptions, _ := NewImageOrPrintOptions() | |
| imageOrPrintOptions.SetImageType(ImageType_Png) | |
| imageOrPrintOptions.SetHorizontalResolution(96) | |
| imageOrPrintOptions.SetVerticalResolution(96) | |
| sheetRender, _ := NewSheetRender(worksheet, imageOrPrintOptions) | |
| stream, _ := sheetRender.ToImage_Int(0) | |
| file, _ := os.OpenFile("67338401.png", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) | |
| defer file.Close() | |
| file.Write(stream) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "os" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("67338402.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| imageOrPrintOptions, _ := NewImageOrPrintOptions() | |
| imageOrPrintOptions.SetImageType(ImageType_Svg) | |
| imageOrPrintOptions.SetHorizontalResolution(96) | |
| imageOrPrintOptions.SetVerticalResolution(96) | |
| sheetRender, _ := NewSheetRender(worksheet, imageOrPrintOptions) | |
| stream, _ := sheetRender.ToImage_Int(0) | |
| file, _ := os.OpenFile("67338403.svg", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) | |
| defer file.Close() | |
| file.Write(stream) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "os" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("67338402.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| imageOrPrintOptions, _ := NewImageOrPrintOptions() | |
| imageOrPrintOptions.SetImageType(ImageType_Tiff) | |
| imageOrPrintOptions.SetHorizontalResolution(96) | |
| imageOrPrintOptions.SetVerticalResolution(96) | |
| sheetRender, _ := NewSheetRender(worksheet, imageOrPrintOptions) | |
| stream, _ := sheetRender.ToImage_Int(0) | |
| file, _ := os.OpenFile("67338419.tiff", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) | |
| defer file.Close() | |
| file.Write(stream) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open the template file | |
| wb, _ := NewWorkbook_String(srcDir + "Book1.xlsx") | |
| // Get the first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Define LoadOptions and set LoadFilter | |
| options, _ := NewLoadOptions() | |
| loadFilter, _ := NewLoadFilter() // Changed to correct overload with no parameters | |
| options.SetLoadFilter(loadFilter) | |
| // To remove the white border around the image. | |
| pageSetup, _ := sheet.GetPageSetup() | |
| pageSetup.SetLeftMargin(0) | |
| pageSetup.SetRightMargin(0) | |
| pageSetup.SetBottomMargin(0) | |
| pageSetup.SetTopMargin(0) | |
| // Define ImageOrPrintOptions | |
| imgOptions, _ := NewImageOrPrintOptions() | |
| imgOptions.SetImageType(ImageType_Emf) // Changed to correct constant definition | |
| // Set only one page would be rendered for the image | |
| imgOptions.SetOnePagePerSheet(true) | |
| imgOptions.SetPrintingPage(PrintingPageType_IgnoreBlank) | |
| // Create the SheetRender object based on the sheet with its ImageOrPrintOptions attributes | |
| sr, _ := NewSheetRender(sheet, imgOptions) | |
| // Convert the image | |
| sr.ToImage_Int_String(0, outDir + "outputRemoveWhitespaceAroundData.emf") // Added method overload with parameters | |
| fmt.Println("Image converted successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| designerFile := "..\\Data\\01_SourceDirectory\\SampleInput.xls" | |
| // Path of output pdf file | |
| pdfFile := outDir + "Output.out.pdf" | |
| defer func() { | |
| if r := recover(); r != nil { | |
| fmt.Println("Error:", r) | |
| } | |
| }() | |
| // Open the template excel file | |
| wb, _ := NewWorkbook_String(designerFile) | |
| // Save the pdf file | |
| wb.Save_String_SaveFormat(pdfFile, SaveFormat_Pdf) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Get the template excel file path | |
| designerFile := srcDir + "SampleInput.xlsx" | |
| // Specify the pdf file path | |
| pdfFile := outDir + "Output.out.pdf" | |
| // Open the template excel file | |
| wb, _ := NewWorkbook_String(designerFile) | |
| // Save the pdf file | |
| wb.Save_String_SaveFormat(pdfFile, SaveFormat_Pdf) | |
| fmt.Println("PDF file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source and output directory paths | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create input and output file paths | |
| inputFilePath := srcDir + "FirstWorkbook.xlsx" | |
| outputFilePath := outDir + "FirstWorkbookMoved_out.xlsx" | |
| // Load source workbook | |
| excelWorkbook2, _ := NewWorkbook_String(inputFilePath) | |
| // Access worksheet collection and move target sheet | |
| sheets, _ := excelWorkbook2.GetWorksheets() | |
| targetSheet, _ := sheets.Get_String("Move") | |
| targetSheet.MoveTo(2) | |
| // Save modified workbook | |
| excelWorkbook2.Save_String(outputFilePath) | |
| fmt.Println("Worksheet moved successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source and output directories | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open source workbooks | |
| excelWorkbook3, _ := NewWorkbook_String(srcDir + "FirstWorkbook.xlsx") | |
| excelWorkbook4, _ := NewWorkbook_String(srcDir + "SecondWorkbook.xlsx") | |
| // Access worksheets collection from second workbook | |
| sheets4, _ := excelWorkbook4.GetWorksheets() | |
| // Add new worksheet to destination workbook | |
| wss, _ := sheets4.Add() | |
| // Copy specified worksheet from source to destination | |
| sourceSheetCollection, _ := excelWorkbook3.GetWorksheets() | |
| sourceSheet, _ := sourceSheetCollection.Get_String("Copy") | |
| sheet, _ := sheets4.Get_Int(wss) | |
| _ = sheet.Copy_Worksheet(sourceSheet) | |
| // Save modified workbook | |
| _ = excelWorkbook4.Save_String(outDir + "CopyWorksheetsBetweenWorkbooks_out.xlsx") | |
| fmt.Println("Worksheets copied successfully between workbooks.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source and output directories | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open first workbook | |
| excelWorkbook5, _ := NewWorkbook_String(srcDir + "FirstWorkbook.xlsx") | |
| // Open second workbook and add new worksheet | |
| excelWorkbook6, _ := NewWorkbook_String(srcDir + "SecondWorkbook.xlsx") | |
| wss6, _ := excelWorkbook6.GetWorksheets() | |
| _ , _ = wss6.Add() | |
| // Copy third worksheet from first workbook to third position in second workbook | |
| wss5, _ := excelWorkbook5.GetWorksheets() | |
| ws5, _ := wss5.Get_Int(2) | |
| wsName, _ := ws5.GetName() | |
| _, _ = wss6.Add_String(wsName) | |
| // Remove copied worksheet from source workbook | |
| count5, _ := wss5.GetCount() | |
| _ = wss5.RemoveAt_Int(count5 - 1) | |
| // Save modified workbooks | |
| excelWorkbook5.Save_String(outDir + "FirstWorkbookWithMove_out.xlsx") | |
| excelWorkbook6.Save_String(outDir + "SecondWorkbookWithMove_out.xlsx") | |
| fmt.Println("Worksheets moved successfully between workbooks.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source and output directory paths | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook from input file | |
| excelWorkbook1, _ := NewWorkbook_String(srcDir + "FirstWorkbook.xlsx") | |
| // Get worksheet collection reference | |
| worksheets, _ := excelWorkbook1.GetWorksheets() | |
| // Copy third worksheet (index 2) within the workbook | |
| worksheets.AddCopy_Int(2) | |
| // Save modified workbook | |
| excelWorkbook1.Save_String(outDir + "FirstWorkbookCopied_out.xlsx") | |
| fmt.Println("Worksheet copied successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("sampleCopyingRowsAndColumns.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cells.CopyColumn(cells, 2, 7) | |
| workbook.Save_String("outputCopyingRowsAndColumns.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("sampleCopyingRowsAndColumns.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cells.CopyRow(cells, 1, 15) | |
| workbook.Save_String("outputCopyingRowsAndColumns.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| wb, _ := NewWorkbook() | |
| worksheets, _ := wb.GetWorksheets() | |
| worksheets.Add_String("TestSheet1") | |
| worksheets.Add_String("TestSheet2") | |
| wss, _ := wb.GetWorksheets() | |
| testSheet1, _ := wss.Get_String("TestSheet1") | |
| testSheet2, _ := wss.Get_String("TestSheet2") | |
| pageSetup1, _ := testSheet1.GetPageSetup() | |
| pageSetup1.SetPaperSize(PaperSizeType_PaperA3ExtraTransverse) | |
| pageSize1, _ := pageSetup1.GetPaperSize() | |
| fmt.Printf("Before Paper Size: %d\n", int(pageSize1)) | |
| pageSetup2, _ := testSheet2.GetPageSetup() | |
| pageSize2, _ := pageSetup2.GetPaperSize() | |
| fmt.Printf("Before Paper Size: %d\n", int(pageSize2)) | |
| fmt.Println() | |
| copyOptions, _ := NewCopyOptions() | |
| pageSetup2.Copy(pageSetup1, copyOptions) | |
| pageSize1, _ = pageSetup1.GetPaperSize() | |
| fmt.Printf("After Paper Size: %d\n", int(pageSize1)) | |
| pageSize2, _ = pageSetup2.GetPaperSize() | |
| fmt.Printf("After Paper Size: %d\n", int(pageSize2)) | |
| fmt.Println() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Instantiate a new Workbook. | |
| workbook, _ := NewWorkbook() | |
| // Get all the worksheets in the book. | |
| worksheets, _ := workbook.GetWorksheets() | |
| // Get the first worksheet in the worksheets collection. | |
| ws, _ := worksheets.Get_Int(0) | |
| // Create a range of cells. | |
| cells, _ := ws.GetCells() | |
| sourceRange, _ := cells.CreateRange_String("A1:A2") | |
| // Input some data with some formatting into | |
| // A few cells in the range. | |
| cell, _ := sourceRange.Get(0, 0) | |
| strValue := "Test" | |
| cell.PutValue_String(strValue) | |
| cell, _ = sourceRange.Get(1, 0) | |
| intValue := int32(123) | |
| cell.PutValue_Int(intValue) | |
| // Create target range of cells. | |
| targetRange, _ := cells.CreateRange_String("B1:B2") | |
| // Copy the data of source range to target range | |
| targetRange.CopyData(sourceRange) | |
| fmt.Println("Data copied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Instantiate a new Workbook. | |
| workbook, _ := NewWorkbook() | |
| // Get all the worksheets in the book. | |
| wss, _ := workbook.GetWorksheets() | |
| // Get the first worksheet in the worksheets collection. | |
| ws, _ := wss.Get_Int(0) | |
| // Create a range of cells. | |
| cells, _ := ws.GetCells() | |
| sourceRange, _ := cells.CreateRange_String("A1") | |
| // Input some data with some formattings into | |
| // A few cells in the range. | |
| cell, _ := sourceRange.Get(0, 0) | |
| cell.PutValue_String("Test") | |
| cell, _ = sourceRange.Get(1, 0) | |
| cell.PutValue_Int(123) | |
| // Create target range of cells. | |
| targetRange, _ := cells.CreateRange_String("B1") | |
| // Copy source range to target range in the same worksheet | |
| sourceRange.Copy_Range(targetRange) | |
| // Create a new worksheet. | |
| wss.Add() | |
| ws, _ = wss.Get_Int(1) | |
| cells, _ = ws.GetCells() | |
| targetRange, _ = cells.CreateRange_String("A1") | |
| // Copy source range to target range in another worksheet | |
| sourceRange.Copy_Range(targetRange) | |
| // Copy to another workbook | |
| anotherWorkbook, _ := NewWorkbook() | |
| wss, _ = anotherWorkbook.GetWorksheets() | |
| ws1, _ := wss.Get_Int(0) | |
| cells, _ = ws1.GetCells() | |
| targetRange, _ = cells.CreateRange_String("A1") | |
| // Copy source range to target range in another workbook | |
| sourceRange.Copy_Range(targetRange) | |
| fmt.Println("Copy operations completed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| for i := int32(0); i < 50; i++ { | |
| for j := int32(0); j < 10; j++ { | |
| value := fmt.Sprintf("%d,%d", i, j) | |
| cell, _ := cells.Get_Int_Int(i, j) | |
| cell.PutValue_String(value) | |
| } | |
| } | |
| range1, _ := cells.CreateRange_String_String("A1", "D3") | |
| style, _ := workbook.CreateStyle() | |
| font, _ := style.GetFont() | |
| font.SetName("Calibri") | |
| color, _ := Color_Yellow() | |
| style.SetForegroundColor(color) | |
| style.SetPattern(BackgroundType_Solid) | |
| borders, _ := style.GetBorders() | |
| topBorder, _ := borders.Get(BorderType_TopBorder) | |
| topBorder.SetLineStyle(CellBorderType_Thin) | |
| topBorder.SetColor(color) | |
| bottomBorder, _ := borders.Get(BorderType_BottomBorder) | |
| bottomBorder.SetLineStyle(CellBorderType_Thin) | |
| bottomBorder.SetColor(color) | |
| leftBorder, _ := borders.Get(BorderType_LeftBorder) | |
| leftBorder.SetLineStyle(CellBorderType_Thin) | |
| leftBorder.SetColor(color) | |
| rightBorder, _ := borders.Get(BorderType_RightBorder) | |
| rightBorder.SetLineStyle(CellBorderType_Thin) | |
| rightBorder.SetColor(color) | |
| flag1 := new(StyleFlag) | |
| flag1.SetFontName(true) | |
| flag1.SetCellShading(true) | |
| flag1.SetBorders(true) | |
| range1.ApplyStyle(style, flag1) | |
| range2, _ := cells.CreateRange_String_String("C10", "F12") | |
| range2.CopyData(range1) | |
| outputPath := outDir + "CopyRangeData.out.xlsx" | |
| workbook.Save_String(outputPath) | |
| fmt.Println("Range data copied and styled successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| workbook, _ := NewWorkbook() | |
| cells, _ := workbook.GetWorksheets() | |
| ws, _ := cells.Get_Int(0) | |
| worksheetCells, _ := ws.GetCells() | |
| for i := int32(0); i < 50; i++ { | |
| for j := int32(0); j < 10; j++ { | |
| cell, _ := worksheetCells.Get_Int_Int(i, j) | |
| value := fmt.Sprintf("%d,%d", i, j) | |
| cell.PutValue_String(value) | |
| } | |
| } | |
| rng, _ := worksheetCells.CreateRange_String_String("A1", "D3") | |
| style, _ := workbook.CreateStyle() | |
| font, _ := style.GetFont() | |
| font.SetName("Calibri") | |
| colorYellow, _ := Color_Yellow() | |
| style.SetForegroundColor(colorYellow) | |
| style.SetPattern(BackgroundType_Solid) | |
| borders, _ := style.GetBorders() | |
| topBorder, _ := borders.Get(BorderType_TopBorder) | |
| topBorder.SetLineStyle(CellBorderType_Thin) | |
| colorBlue, _ := Color_Blue() | |
| topBorder.SetColor(colorBlue) | |
| bottomBorder, _ := borders.Get(BorderType_BottomBorder) | |
| bottomBorder.SetLineStyle(CellBorderType_Thin) | |
| bottomBorder.SetColor(colorBlue) | |
| leftBorder, _ := borders.Get(BorderType_LeftBorder) | |
| leftBorder.SetLineStyle(CellBorderType_Thin) | |
| leftBorder.SetColor(colorBlue) | |
| rightBorder, _ := borders.Get(BorderType_RightBorder) | |
| rightBorder.SetLineStyle(CellBorderType_Thin) | |
| rightBorder.SetColor(colorBlue) | |
| flag1 := new(StyleFlag) | |
| flag1.SetFontName(true) | |
| flag1.SetCellShading(true) | |
| flag1.SetBorders(true) | |
| rng.ApplyStyle(style, flag1) | |
| range2, _ := worksheetCells.CreateRange_String_String("C10", "F12") | |
| range2.Merge() | |
| outputPath := outDir + "CopyRange.out.xlsx" | |
| workbook.Save_String(outputPath) | |
| fmt.Println("Range copied with formatting successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| for i := int32(0); i < 50; i++ { | |
| for j := int32(0); j < 10; j++ { | |
| value := fmt.Sprintf("%d,%d", i, j) | |
| cell, _ := cells.Get_Int_Int(i, j) | |
| cell.PutValue_String(value) | |
| } | |
| } | |
| rng, _ := cells.CreateRange_String_String("A1", "D3") | |
| style, _ := workbook.CreateStyle() | |
| font, _ := style.GetFont() | |
| font.SetName("Calibri") | |
| yellow, _ := Color_Yellow() | |
| style.SetForegroundColor(yellow) | |
| style.SetPattern(BackgroundType_Solid) | |
| borders, _ := style.GetBorders() | |
| topBorder, _ := borders.Get(BorderType_TopBorder) | |
| topBorder.SetLineStyle(CellBorderType_Thin) | |
| blue, _ := Color_Blue() | |
| topBorder.SetColor(blue) | |
| bottomBorder, _ := borders.Get(BorderType_BottomBorder) | |
| bottomBorder.SetLineStyle(CellBorderType_Thin) | |
| bottomBorder.SetColor(blue) | |
| leftBorder, _ := borders.Get(BorderType_LeftBorder) | |
| leftBorder.SetLineStyle(CellBorderType_Thin) | |
| leftBorder.SetColor(blue) | |
| rightBorder, _ := borders.Get(BorderType_RightBorder) | |
| rightBorder.SetLineStyle(CellBorderType_Thin) | |
| rightBorder.SetColor(blue) | |
| flag1 := new(StyleFlag) | |
| flag1.SetFontName(true) | |
| flag1.SetCellShading(true) | |
| flag1.SetBorders(true) | |
| rng.ApplyStyle(style, flag1) | |
| range2, _ := cells.CreateRange_String_String("C10", "E13") | |
| range2.CopyStyle(rng) | |
| outputPath := outDir + "copyrangestyle.out.xls" | |
| workbook.Save_String(outputPath) | |
| fmt.Println("Range style copied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook object | |
| workbook, _ := NewWorkbook() | |
| // Source worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| srcSheet, _ := wss.Get_Int(0) | |
| // Add destination worksheet | |
| dstSheet, _ := wss.Add_String("Destination Sheet") | |
| // Set the row height of the 4th row. This row height will be copied to destination range | |
| cells, _ := srcSheet.GetCells() | |
| cells.SetRowHeight(3, 50) | |
| // Create source range to be copied | |
| srcRange, _ := cells.CreateRange_String("A1:D10") | |
| // Create destination range in destination worksheet | |
| dstCells, _ := dstSheet.GetCells() | |
| dstRange, _ := dstCells.CreateRange_String("A1:D10") | |
| // PasteOptions, we want to copy row heights of source range to destination range | |
| opts := new(PasteOptions) | |
| opts.SetPasteType(PasteType_RowHeights) | |
| // Copy source range to destination range with paste options | |
| srcRange.Copy_Range_PasteOptions(dstRange, opts) | |
| // Write informative message in cell D4 of destination worksheet | |
| cell, _ := dstCells.Get_String("D4") | |
| cell.PutValue_String("Row heights of source range copied to destination range") | |
| // Save the workbook in xlsx format | |
| workbook.Save_String_SaveFormat(outDir + "output_out.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("Row heights copied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "sample2.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "ControlsCopied_out.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Get the Shapes from the "Control" worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| controlSheet, _ := wss.Get_String("Control") | |
| shapes, _ := controlSheet.GetShapes() | |
| // Copy the Textbox to the Result Worksheet | |
| resultSheet, _ := wss.Get_String("Result") | |
| shape0, _ := shapes.Get_Int(0) | |
| resultShapes, _ := resultSheet.GetShapes() | |
| resultShapes.AddCopy(shape0, 5, 0, 2, 0) | |
| // Copy the Oval Shape to the Result Worksheet | |
| shape1, _ := shapes.Get_Int(1) | |
| resultShapes.AddCopy(shape1, 10, 0, 2, 0) | |
| // Save the Worksheet | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Shapes copied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "../Data/01_SourceDirectory/" | |
| // Output directory path | |
| outDir := "../Data/02_OutputDirectory/" | |
| // Create workbook from source Excel file | |
| workbook, _ := NewWorkbook_String(srcDir + "source.xlsx") | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the first sparkline group | |
| sparklineGroups, _ := worksheet.GetSparklineGroups() | |
| group, _ := sparklineGroups.Get(0) | |
| // Add Data Ranges and Locations inside this sparkline group | |
| sparklines, _ := group.GetSparklines() | |
| sparklines.Add("D5:O5", 4, 15) | |
| sparklines.Add("D6:O6", 5, 15) | |
| sparklines.Add("D7:O7", 6, 15) | |
| sparklines.Add("D8:O8", 7, 15) | |
| // Save the workbook | |
| workbook.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Sparklines added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("sampleCopyingAndMovingWorksheets.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheets.AddCopy_String("Sheet1") | |
| workbook.Save_String("outputCopyingAndMovingWorksheets.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Load source Excel file | |
| workbook, _ := NewWorkbook_String(sourceDir + "BookWithSomeData.xlsx") | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Print number of cells in the Worksheet | |
| cells, _ := worksheet.GetCells() | |
| cellCount, _ := cells.GetCount() | |
| fmt.Printf("Number of Cells: %d\n", cellCount) | |
| // In case the number of cells is greater than 2147483647, use CountLarge | |
| cellCountLarge, _ := cells.GetCountLarge() | |
| fmt.Printf("Number of Cells (CountLarge): %d\n", cellCountLarge) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiate a new Workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet in the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet1, _ := wss.Get_Int(0) | |
| // Create a range of cells based on H1:J4 | |
| cells, _ := worksheet1.GetCells() | |
| cellRange, _ := cells.CreateRange_String_String("H1", "J4") | |
| // Name the range | |
| cellRange.SetName("MyRange") | |
| // Input some data into cells in the range | |
| cell0_0, _ := cellRange.Get(0, 0) | |
| cell0_0.PutValue_String("USA") | |
| cell0_1, _ := cellRange.Get(0, 1) | |
| cell0_1.PutValue_String("SA") | |
| cell0_2, _ := cellRange.Get(0, 2) | |
| cell0_2.PutValue_String("Israel") | |
| cell1_0, _ := cellRange.Get(1, 0) | |
| cell1_0.PutValue_String("UK") | |
| cell1_1, _ := cellRange.Get(1, 1) | |
| cell1_1.PutValue_String("AUS") | |
| cell1_2, _ := cellRange.Get(1, 2) | |
| cell1_2.PutValue_String("Canada") | |
| cell2_0, _ := cellRange.Get(2, 0) | |
| cell2_0.PutValue_String("France") | |
| cell2_1, _ := cellRange.Get(2, 1) | |
| cell2_1.PutValue_String("India") | |
| cell2_2, _ := cellRange.Get(2, 2) | |
| cell2_2.PutValue_String("Egypt") | |
| cell3_0, _ := cellRange.Get(3, 0) | |
| cell3_0.PutValue_String("China") | |
| cell3_1, _ := cellRange.Get(3, 1) | |
| cell3_1.PutValue_String("Philippine") | |
| cell3_2, _ := cellRange.Get(3, 2) | |
| cell3_2.PutValue_String("Brazil") | |
| // Save the excel file | |
| workbook.Save_String(outDir + "rangecells.out.xls") | |
| fmt.Println("Range cells created and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "book1.xls" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Getting the specified named range | |
| wsCollection, _ := workbook.GetWorksheets() | |
| namedRanges, _ := wsCollection.GetNamedRanges() | |
| if namedRanges != nil { | |
| range_, _ := namedRanges[0].GetRefersTo() // Correcting the access of element from slice with function | |
| fmt.Println("Named Range :", range_) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| inputFilePath := srcDir + "book1.xls" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| sheets, _ := workbook.GetWorksheets() | |
| ranges, _ := sheets.GetNamedRanges() | |
| length := len(ranges) | |
| fmt.Println("Total Number of Named Ranges:", length) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "book1.xls" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "output.out.xls" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Accessing the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Creating a named range | |
| cells, _ := worksheet.GetCells() | |
| namedRange, _ := cells.CreateRange_String("B4:G14") | |
| // Setting the name of the named range | |
| namedRange.SetName("TestRange") | |
| // Saving the modified Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Named range created and file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create an instance of Workbook | |
| book, _ := NewWorkbook() | |
| // Access first worksheet from the collection | |
| wss, _ := book.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Access cells collection of the first worksheet | |
| cells, _ := sheet.GetCells() | |
| // Insert data column wise | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Category") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("Fruit") | |
| cell, _ = cells.Get_String("A6") | |
| cell.PutValue_String("Vegetables") | |
| cell, _ = cells.Get_String("A7") | |
| cell.PutValue_String("Vegetables") | |
| cell, _ = cells.Get_String("A8") | |
| cell.PutValue_String("Vegetables") | |
| cell, _ = cells.Get_String("A9") | |
| cell.PutValue_String("Vegetables") | |
| cell, _ = cells.Get_String("A10") | |
| cell.PutValue_String("Beverages") | |
| cell, _ = cells.Get_String("A11") | |
| cell.PutValue_String("Beverages") | |
| cell, _ = cells.Get_String("A12") | |
| cell.PutValue_String("Beverages") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Food") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_String("Apple") | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_String("Banana") | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_String("Apricot") | |
| cell, _ = cells.Get_String("B5") | |
| cell.PutValue_String("Grapes") | |
| cell, _ = cells.Get_String("B6") | |
| cell.PutValue_String("Carrot") | |
| cell, _ = cells.Get_String("B7") | |
| cell.PutValue_String("Onion") | |
| cell, _ = cells.Get_String("B8") | |
| cell.PutValue_String("Cabbage") | |
| cell, _ = cells.Get_String("B9") | |
| cell.PutValue_String("Potato") | |
| cell, _ = cells.Get_String("B10") | |
| cell.PutValue_String("Coke") | |
| cell, _ = cells.Get_String("B11") | |
| cell.PutValue_String("Coladas") | |
| cell, _ = cells.Get_String("B12") | |
| cell.PutValue_String("Fizz") | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_Double(2.2) | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_Double(3.1) | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_Double(4.1) | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_Double(5.1) | |
| cell, _ = cells.Get_String("C5") | |
| cell.PutValue_Double(4.4) | |
| cell, _ = cells.Get_String("C6") | |
| cell.PutValue_Double(5.4) | |
| cell, _ = cells.Get_String("C7") | |
| cell.PutValue_Double(6.5) | |
| cell, _ = cells.Get_String("C8") | |
| cell.PutValue_Double(5.3) | |
| cell, _ = cells.Get_String("C9") | |
| cell.PutValue_Double(3.2) | |
| cell, _ = cells.Get_String("C10") | |
| cell.PutValue_Double(3.6) | |
| cell, _ = cells.Get_String("C11") | |
| cell.PutValue_Double(5.2) | |
| cell, _ = cells.Get_String("D1") | |
| cell.PutValue_String("Profit") | |
| cell, _ = cells.Get_String("D2") | |
| cell.PutValue_Double(0.1) | |
| cell, _ = cells.Get_String("D3") | |
| cell.PutValue_Double(0.4) | |
| cell, _ = cells.Get_String("D4") | |
| cell.PutValue_Double(0.5) | |
| cell, _ = cells.Get_String("D5") | |
| cell.PutValue_Double(0.6) | |
| cell, _ = cells.Get_String("D6") | |
| cell.PutValue_Double(0.7) | |
| cell, _ = cells.Get_String("D7") | |
| cell.PutValue_Double(1.3) | |
| cell, _ = cells.Get_String("D8") | |
| cell.PutValue_Double(0.8) | |
| cell, _ = cells.Get_String("D9") | |
| cell.PutValue_Double(1.3) | |
| cell, _ = cells.Get_String("D10") | |
| cell.PutValue_Double(2.2) | |
| cell, _ = cells.Get_String("D11") | |
| cell.PutValue_Double(2.4) | |
| cell, _ = cells.Get_String("D12") | |
| cell.PutValue_Double(3.3) | |
| // Create ListObject, Get the List objects collection in the first worksheet | |
| listObjects, _ := sheet.GetListObjects() | |
| // Add a List based on the data source range with headers on | |
| index, _ := listObjects.Add_String_String_Bool("A1:D1", "A1:D12", true) | |
| sheet.AutoFitColumns() | |
| // Create chart based on ListObject | |
| charts, _ := sheet.GetCharts() | |
| index, _ = charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 21, 1, 35, 18) | |
| chart, _ := charts.Get_Int(index) | |
| chart.SetChartDataRange("A1:D12", true) | |
| series, _ := chart.GetNSeries() | |
| series.SetCategoryData("A2:A12") | |
| // Save spreadsheet | |
| book.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Spreadsheet created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create an instance of Workbook | |
| inputFilePath := "Open-High-Low-Close.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Create High-Low-Close-Stock Chart | |
| charts, _ := ws.GetCharts() | |
| pieIdx, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_StockOpenHighLowClose, 5, 6, 20, 12) | |
| // Retrieve the Chart object | |
| chart, _ := charts.Get_Int(pieIdx) | |
| // Set the legend can be showed | |
| chart.SetShowLegend(true) | |
| // Set the chart title name | |
| title, _ := chart.GetTitle() | |
| title.SetText("Open-High-Low-Close Stock") | |
| // Set the Legend at the bottom of the chart area | |
| legend, _ := chart.GetLegend() | |
| legend.SetPosition(LegendPositionType_Bottom) | |
| // Set data range | |
| chart.SetChartDataRange("A1:E9", true) | |
| // Set category data | |
| nSeries, _ := chart.GetNSeries() | |
| nSeries.SetCategoryData("A2:A9") | |
| // Set the DownBars and UpBars with different color | |
| downBars, _ := nSeries.Get(0) | |
| downBarArea, _ := downBars.GetDownBars() | |
| downBarAreaArea, _ := downBarArea.GetArea() | |
| colorGreen, _ := Color_Green() | |
| downBarAreaArea.SetForegroundColor(colorGreen) | |
| upBars, _ := nSeries.Get(0) | |
| upBarArea, _ := upBars.GetUpBars() | |
| upBarAreaArea, _ := upBarArea.GetArea() | |
| colorRed, _ := Color_Red() | |
| upBarAreaArea.SetForegroundColor(colorRed) | |
| // Fill the PlotArea area with nothing | |
| plotArea, _ := chart.GetPlotArea() | |
| plotAreaArea, _ := plotArea.GetArea() | |
| fillFormat, _ := plotAreaArea.GetFillFormat() | |
| fillFormat.SetFillType(FillType_None) | |
| // Save the Excel file | |
| wb.Save_String("out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Load sample Excel file | |
| inputFilePath := "sampleCreatePdfBookmarkEntryForChartSheet.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access all four worksheets | |
| wss, _ := wb.GetWorksheets() | |
| sheet1, _ := wss.Get_Int(0) | |
| sheet2, _ := wss.Get_Int(1) | |
| sheet3, _ := wss.Get_Int(2) | |
| sheet4, _ := wss.Get_Int(3) | |
| // Create Pdf Bookmark Entry for Sheet1 | |
| ent1, _ := NewPdfBookmarkEntry() | |
| cells1, _ := sheet1.GetCells() | |
| cell1, _ := cells1.Get_String("A1") | |
| ent1.SetDestination(cell1) | |
| ent1.SetText("Bookmark-I") | |
| // Create Pdf Bookmark Entry for Sheet2 - Chart | |
| ent2, _ := NewPdfBookmarkEntry() | |
| cells2, _ := sheet2.GetCells() | |
| cell2, _ := cells2.Get_String("A1") | |
| ent2.SetDestination(cell2) | |
| ent2.SetText("Bookmark-II-Chart1") | |
| // Create Pdf Bookmark Entry for Sheet3 | |
| ent3, _ := NewPdfBookmarkEntry() | |
| cells3, _ := sheet3.GetCells() | |
| cell3, _ := cells3.Get_String("A1") | |
| ent3.SetDestination(cell3) | |
| ent3.SetText("Bookmark-III") | |
| // Create Pdf Bookmark Entry for Sheet4 - Chart | |
| ent4, _ := NewPdfBookmarkEntry() | |
| cells4, _ := sheet4.GetCells() | |
| cell4, _ := cells4.Get_String("A1") | |
| ent4.SetDestination(cell4) | |
| ent4.SetText("Bookmark-IV-Chart2") | |
| // Create Pdf Save Options with Bookmark Entries | |
| opts, _ := NewPdfSaveOptions() | |
| opts.SetBookmark(ent1) | |
| // Save the output Pdf | |
| outputFilePath := "outputCreatePdfBookmarkEntryForChartSheet.pdf" | |
| wb.Save_String_SaveOptions(outputFilePath, opts.ToSaveOptions()) | |
| println("PDF with bookmarks created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "pivotTable_test.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "pivotChart_test_out.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Adding a new sheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheetIndex, _ := wss.Add() | |
| sheet3, _ := wss.Get_Int(worksheetIndex) | |
| // Naming the sheet | |
| sheet3.SetName("PivotChart") | |
| // Adding a column chart | |
| charts, _ := sheet3.GetCharts() | |
| index, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 0, 5, 28, 16) | |
| // Setting the pivot chart data source | |
| chart, _ := charts.Get_Int(index) | |
| chart.SetPivotSource("PivotTable!PivotTable1") | |
| chart.SetHidePivotFieldButtons(false) | |
| // Saving the Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Pivot chart created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Name the sheet | |
| ws.SetName("Data") | |
| // Get the cells collection | |
| cells, _ := ws.GetCells() | |
| // Set values to the cells | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Employee") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("Quarter") | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("Product") | |
| cell, _ = cells.Get_String("D1") | |
| cell.PutValue_String("Continent") | |
| cell, _ = cells.Get_String("E1") | |
| cell.PutValue_String("Country") | |
| cell, _ = cells.Get_String("F1") | |
| cell.PutValue_String("Sale") | |
| // Fill employee names | |
| names := []string{"David", "David", "David", "David", "James", "James", "James", "James", "James", "Miya", "Miya", "Miya", "Miya", "Miya", "Miya", "Miya", "Miya", "Elvis", "Elvis", "Elvis", "Elvis", "Elvis", "Elvis", "Elvis", "Jean", "Jean", "Jean", "Ada", "Ada", "Ada"} | |
| for i, name := range names { | |
| cell, _ := cells.Get_String(fmt.Sprintf("A%d", i+2)) | |
| cell.PutValue_String(name) | |
| } | |
| // Fill quarters | |
| quarters := []int32{1, 2, 3, 4, 1, 2, 3, 4, 4, 1, 1, 2, 2, 3, 4, 4, 1, 1, 2, 3, 3, 4, 4, 1, 2, 3, 1, 2, 3} | |
| for i, quarter := range quarters { | |
| cell, _ := cells.Get_String(fmt.Sprintf("B%d", i+2)) | |
| cell.PutValue_Int(quarter) | |
| } | |
| // Fill products | |
| products := []string{"Maxilaku", "Maxilaku", "Chai", "Maxilaku", "Chang", "Chang", "Chang", "Chang", "Chang", "Geitost", "Chai", "Geitost", "Geitost", "Maxilaku", "Geitost", "Geitost", "Ikuru", "Ikuru", "Ikuru", "Ikuru", "Ipoh Coffee", "Ipoh Coffee", "Ipoh Coffee", "Chocolade", "Chocolade", "Chocolade", "Chocolade", "Chocolade", "Chocolade"} | |
| for i, product := range products { | |
| cell, _ := cells.Get_String(fmt.Sprintf("C%d", i+2)) | |
| cell.PutValue_String(product) | |
| } | |
| // Fill continents | |
| continents := []string{"Asia", "Asia", "Asia", "Asia", "Europe", "Europe", "Europe", "Europe", "Europe", "America", "America", "America", "America", "America", "America", "America", "America", "Europe", "Europe", "Europe", "Oceania", "Oceania", "Oceania", "Oceania", "Africa", "Africa", "Africa", "Africa", "Africa", "Africa"} | |
| for i, continent := range continents { | |
| cell, _ := cells.Get_String(fmt.Sprintf("D%d", i+2)) | |
| cell.PutValue_String(continent) | |
| } | |
| // Fill countries | |
| countries := []string{"China", "India", "Korea", "India", "France", "France", "Germany", "Italy", "France", "U.S.", "U.S.", "Brazil", "U.S.", "U.S.", "Canada", "U.S.", "Italy", "France", "Italy", "New Zealand", "Australia", "Australia", "New Zealand", "S.Africa", "S.Africa", "S.Africa", "Egypt", "Egypt", "Egypt"} | |
| for i, country := range countries { | |
| cell, _ := cells.Get_String(fmt.Sprintf("E%d", i+2)) | |
| cell.PutValue_String(country) | |
| } | |
| // Fill sales | |
| sales := []int32{2000, 500, 1200, 1500, 500, 1500, 800, 900, 500, 1600, 600, 2000, 500, 900, 700, 1400, 1350, 300, 500, 1000, 1500, 1500, 1600, 1000, 1200, 1300, 1500, 1400, 1000} | |
| for i, sale := range sales { | |
| cell, _ := cells.Get_String(fmt.Sprintf("F%d", i+2)) | |
| cell.PutValue_Int(sale) | |
| } | |
| // Add a new sheet | |
| index, _ := wss.Add() | |
| sheet2, _ := wss.Get_Int(index) | |
| sheet2.SetName("PivotTable") | |
| // Get the pivot tables collection | |
| pivotTables, _ := sheet2.GetPivotTables() | |
| // Add a pivot table | |
| index, _ = pivotTables.Add_String_String_String("=Data!A1:F30", "B3", "PivotTable1") | |
| pivotTable, _ := pivotTables.Get_Int(index) | |
| // Show grand totals | |
| pivotTable.SetShowRowGrandTotals(true) | |
| pivotTable.SetShowColumnGrandTotals(true) | |
| // Set auto format | |
| pivotTable.SetIsAutoFormat(true) | |
| pivotTable.SetAutoFormatType(PivotTableAutoFormatType_Report6) | |
| // Add fields to row area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 0) | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 2) | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 1) | |
| // Add fields to column area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Column, 3) | |
| // Add fields to data area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Data, 5) | |
| // Set number format for the first data field | |
| dataFields, _ := pivotTable.GetDataFields() | |
| dataField, _ := dataFields.Get_Int(0) | |
| dataField.SetNumberFormat("$#,##0.00") | |
| // Save the workbook | |
| workbook.Save_String(outDir + "pivotTable_test.out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "../Data/02_OutputDirectory/" | |
| // Create workbook object | |
| workbook, _ := NewWorkbook() | |
| // Create signature line object | |
| s, _ := NewSignatureLine() | |
| s.SetSigner("John Doe") | |
| s.SetTitle("Development Lead") | |
| s.SetEmail("john.doe@aspose.com") | |
| // Adds a Signature Line to the worksheet. | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| shapes, _ := ws.GetShapes() | |
| shapes.AddSignatureLine(1, 1, s) | |
| // Save the workbook | |
| outputFilePath := outDir + "output_out.xlsx" | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Workbook saved successfully with signature line!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a Style object using CellsFactory class | |
| cf := CellsFactory{} | |
| st, _ := cf.CreateStyle() | |
| // Set the Style fill color to Yellow | |
| st.SetPattern(BackgroundType_Solid) | |
| colorObj, _ := Color_Yellow() | |
| st.SetForegroundColor(colorObj) | |
| // Create a workbook and set its default style using the created Style object | |
| wb, _ := NewWorkbook() | |
| wb.SetDefaultStyle(st) | |
| // Save the workbook | |
| wb.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook | |
| wb, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Add text box inside the sheet | |
| shapes, _ := ws.GetShapes() | |
| shapes.AddTextBox(2, 0, 2, 0, 80, 400) | |
| // Access first shape which is a text box and set its text | |
| shapeList, _ := ws.GetShapes() | |
| shape, _ := shapeList.Get_Int(0) | |
| shape.SetText("Sign up for your free phone number.\nCall and text online for free.\nCall your friends and family.") | |
| // Access the first paragraph and set its horizontal alignment to left | |
| textBody, _ := shape.GetTextBody() | |
| textParagraphs, _ := textBody.GetTextParagraphs() | |
| p, _ := textParagraphs.Get(0) | |
| p.SetAlignmentType(TextAlignmentType_Left) | |
| // Access the second paragraph and set its horizontal alignment to center | |
| p, _ = textParagraphs.Get(1) | |
| p.SetAlignmentType(TextAlignmentType_Center) | |
| // Access the third paragraph and set its horizontal alignment to right | |
| p, _ = textParagraphs.Get(2) | |
| p.SetAlignmentType(TextAlignmentType_Right) | |
| // Save the workbook in xlsx format | |
| wb.Save_String_SaveFormat(outDir + "output_out.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook object from source file | |
| workbook, _ := NewWorkbook_String(sourceDir + "sampleCreateTransparentImage.xlsx") | |
| // Apply different image or print options | |
| imgOption := new(ImageOrPrintOptions) | |
| imgOption.SetImageType(ImageType_Png) // Png | |
| imgOption.SetHorizontalResolution(200) | |
| imgOption.SetVerticalResolution(200) | |
| imgOption.SetOnePagePerSheet(true) | |
| // Apply transparency to the output image | |
| imgOption.SetTransparent(true) | |
| // Create image after applying image or print options | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| sr, _ := NewSheetRender(worksheet, imgOption) | |
| sr.ToImage_Int_String(0, outputDir + "outputCreateTransparentImage.png") | |
| fmt.Println("Image created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a Workbook object | |
| workbook, _ := NewWorkbook() | |
| // Create union range | |
| wss, _ := workbook.GetWorksheets() | |
| unionRange, _ := wss.CreateUnionRange("sheet1!A1:A10,sheet1!C1:C10", 0) | |
| // Put value "ABCD" in the range | |
| obj, _ := NewObject_String("ABCD") | |
| unionRange.SetValue(obj) | |
| // Save the output workbook | |
| workbook.Save_String("CreateUnionRange_out.xlsx") | |
| fmt.Println("Union range created and workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create an instance of Workbook | |
| inputFilePath := "Volume-High-Low-Close.xlsx" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Create High-Low-Close Stock Chart | |
| charts, _ := worksheet.GetCharts() | |
| pieIdx, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_StockVolumeHighLowClose, 5, 6, 20, 12) | |
| // Retrieve the Chart object | |
| chart, _ := charts.Get_Int(pieIdx) | |
| // Set the legend can be showed | |
| chart.SetShowLegend(true) | |
| // Set the chart title name | |
| title, _ := chart.GetTitle() | |
| title.SetText("Volume-High-Low-Close Stock") | |
| // Set the Legend at the bottom of the chart area | |
| legend, _ := chart.GetLegend() | |
| legend.SetPosition(LegendPositionType_Bottom) | |
| // Set data range | |
| chart.SetChartDataRange("A1:E9", true) | |
| // Set category data | |
| nSeries, _ := chart.GetNSeries() | |
| nSeries.SetCategoryData("A2:A9") | |
| // Set Color for the first series (Volume) data | |
| series, _ := nSeries.Get(0) | |
| area, _ := series.GetArea() | |
| fillFormat, _ := area.GetFillFormat() | |
| _ = fillFormat.SetFillType(FillType_None) | |
| // Save the Excel file | |
| workbook.Save_String("out.xlsx") | |
| fmt.Println("Chart created and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create an instance of Workbook | |
| workbook, _ := NewWorkbook_String("Volume-Open-High-Low-Close.xlsx") | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Create High-Low-Close-Stock Chart | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_StockVolumeOpenHighLowClose, 5, 6, 20, 12) | |
| // Retrieve the Chart object | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Set the legend to be shown | |
| chart.SetShowLegend(true) | |
| // Set the chart title name | |
| title, _ := chart.GetTitle() | |
| title.SetText("Volume-Open-High-Low-Close Stock") | |
| // Set the Legend at the bottom of the chart area | |
| legend, _ := chart.GetLegend() | |
| legend.SetPosition(LegendPositionType_Bottom) | |
| // Set data range | |
| chart.SetChartDataRange("A1:F9", true) | |
| // Set category data | |
| nseries, _ := chart.GetNSeries() | |
| nseries.SetCategoryData("A2:A9") | |
| // Set Color for the first series (Volume) data | |
| series, _ := nseries.Get(0) | |
| area, _ := series.GetArea() | |
| color, _ := Color_FromArgb(0xff) | |
| area.SetForegroundColor(color) | |
| // Fill the PlotArea area with nothing | |
| plotArea, _ := chart.GetPlotArea() | |
| plotAreaArea, _ := plotArea.GetArea() | |
| fillFormat, _ := plotAreaArea.GetFillFormat() | |
| fillFormat.SetFillType(FillType_None) | |
| // Save the Excel file | |
| workbook.Save_String("out.xlsx") | |
| fmt.Println("Chart created and file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("book1.xls") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| listObjects, _ := worksheet.GetListObjects() | |
| index, _ := listObjects.Add_Int_Int_Int_Int_Bool(1, 1, 7, 5, true) | |
| listObject, _ := listObjects.Get_Int(index) | |
| listObject.SetTableStyleType(TableStyleType_TableStyleMedium10) | |
| listObject.SetShowTotals(true) | |
| workbook.Save_String("CreatingListObjects_out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create an instance of Workbook | |
| workbook, _ := NewWorkbook_String("sunburst.xlsx") | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Add a Treemap chart | |
| charts, _ := worksheet.GetCharts() | |
| pieIdx, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Sunburst, 5, 6, 25, 12) | |
| // Retrieve the Chart object | |
| chart, _ := charts.Get_Int(pieIdx) | |
| // Set the legend can be showed | |
| chart.SetShowLegend(true) | |
| // Set the chart title name | |
| title, _ := chart.GetTitle() | |
| title.SetText("Sunburst Chart") | |
| // Add series data range | |
| series, _ := chart.GetNSeries() | |
| series.Add_String_Bool("D2:D16", true) | |
| // Set category data (A2:A16 is incorrect, as hierarchical category) | |
| series.SetCategoryData("A2:C16") | |
| // Show the DataLabels with category names | |
| nSeries, _ := series.Get(0) | |
| dataLabels, _ := nSeries.GetDataLabels() | |
| dataLabels.SetShowCategoryName(true) | |
| // Fill the PlotArea area with nothing | |
| plotArea, _ := chart.GetPlotArea() | |
| area, _ := plotArea.GetArea() | |
| fillFormat, _ := area.GetFillFormat() | |
| fillFormat.SetFillType(FillType_None) | |
| // Save the Excel file | |
| workbook.Save_String("out.xlsx") | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create an instance of Workbook | |
| workbook, _ := NewWorkbook_String("treemap.xlsx") | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Add a Treemap chart | |
| charts, _ := worksheet.GetCharts() | |
| pieIdx, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Treemap, 5, 6, 20, 12) | |
| // Retrieve the Chart object | |
| chart, _ := charts.Get_Int(pieIdx) | |
| // Set the legend can be showed | |
| chart.SetShowLegend(true) | |
| // Set the chart title name | |
| title, _ := chart.GetTitle() | |
| title.SetText("TreeMap Chart") | |
| // Add series data range (D2:F13, actually) | |
| nSeries, _ := chart.GetNSeries() | |
| nSeries.Add_String_Bool("D2:F13", true) | |
| // Set category data (A2:A13 is correct) | |
| nSeries.SetCategoryData("A2:A13") | |
| // Show the DataLabels with category names | |
| series, _ := nSeries.Get(0) | |
| dataLabels, _ := series.GetDataLabels() | |
| dataLabels.SetShowCategoryName(true) | |
| // Fill the PlotArea area with nothing | |
| plotArea, _ := chart.GetPlotArea() | |
| area, _ := plotArea.GetArea() | |
| fillFormat, _ := area.GetFillFormat() | |
| fillFormat.SetFillType(FillType_None) | |
| // Save the Excel file | |
| workbook.Save_String("out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create an instance of Workbook | |
| workbook, _ := NewWorkbook() | |
| // Retrieve the first Worksheet in Workbook | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Retrieve the Cells of the first Worksheet | |
| cells, _ := worksheet.GetCells() | |
| // Input some data which chart will use as source | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_String("Previous Year") | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_String("January") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("March") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("August") | |
| cell, _ = cells.Get_String("A5") | |
| cell.PutValue_String("October") | |
| cell, _ = cells.Get_String("A6") | |
| cell.PutValue_String("Current Year") | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Double(8.5) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Double(1.5) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Double(7.5) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Double(7.5) | |
| cell, _ = cells.Get_String("B5") | |
| cell.PutValue_Double(8.5) | |
| cell, _ = cells.Get_String("B6") | |
| cell.PutValue_Double(3.5) | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_Double(1.5) | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_Double(4.5) | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_Double(3.5) | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_Double(9.5) | |
| cell, _ = cells.Get_String("C5") | |
| cell.PutValue_Double(7.5) | |
| cell, _ = cells.Get_String("C6") | |
| cell.PutValue_Double(9.5) | |
| // Add a Chart of type Waterfall in same worksheet as of data | |
| charts, _ := worksheet.GetCharts() | |
| idx, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Waterfall, 4, 4, 25, 13) | |
| // Retrieve the Chart object | |
| chart, _ := charts.Get_Int(idx) | |
| // Add Series | |
| nSeries, _ := chart.GetNSeries() | |
| seriesIndex, _ := nSeries.Add_String_Bool("$B$1:$C$6", true) | |
| series, _ := nSeries.Get(seriesIndex) | |
| // Series has Up Down Bars | |
| upBars, _ := series.GetUpBars() | |
| upBarsArea, _ := upBars.GetArea() | |
| color_green, _ := Color_Green() | |
| upBarsArea.SetForegroundColor(color_green) | |
| downBars, _ := series.GetDownBars() | |
| downBarsArea, _ := downBars.GetArea() | |
| color_red, _ := Color_Red() | |
| downBarsArea.SetForegroundColor(color_red) | |
| // Make both Series Lines invisible | |
| border, _ := series.GetBorder() | |
| border.SetIsVisible(false) | |
| firstSeries, _ := nSeries.Get(1) | |
| border1, _ := firstSeries.GetBorder() | |
| border1.SetIsVisible(false) | |
| // Set the Plot Area Formatting Automatic | |
| plotArea, _ := chart.GetPlotArea() | |
| plotAreaArea, _ := plotArea.GetArea() | |
| plotAreaArea.SetFormatting(FormattingType_Automatic) | |
| // Delete the Legend | |
| legend, _ := chart.GetLegend() | |
| legendEntries, _ := legend.GetLegendEntries() | |
| entry0, _ := legendEntries.Get(0) | |
| entry0.SetIsDeleted(true) | |
| entry1, _ := legendEntries.Get(1) | |
| entry1.SetIsDeleted(true) | |
| // Save the workbook | |
| workbook.Save_String(outDir + "output_out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access the cell where you want to apply the currency format | |
| cells, _ := ws.GetCells() | |
| a1, _ := cells.Get_String("A1") | |
| // Set a numeric value to the cell | |
| a1.PutValue_Double(1234.56) | |
| // Create a style object to apply the currency format | |
| a1Style, _ := a1.GetStyle() | |
| // "7" is the currency format in Excel | |
| a1Style.SetNumber(7) | |
| // Apply the style to the cell | |
| a1.SetStyle_Style(a1Style) | |
| // Access the cell where you want to apply the currency format | |
| a2, _ := cells.Get_String("A2") | |
| // Set a numeric value to the cell | |
| a2.PutValue_Double(3456.78) | |
| // Create a style object to apply the currency format | |
| a2Style, _ := a2.GetStyle() | |
| // Custom format for dollar currency | |
| a2Style.SetCustom_String("$#,##0.00") | |
| // Apply the style to the cell | |
| a2.SetStyle_Style(a2Style) | |
| // Save the workbook | |
| workbook.Save_String("CurrencyFormatted.xlsx") | |
| fmt.Println("Workbook saved successfully with currency formatting!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| type CustomPivotTableGlobalizationSettings struct { | |
| PivotGlobalizationSettings | |
| } | |
| func (c *CustomPivotTableGlobalizationSettings) GetTextOfTotal() string { | |
| fmt.Println("---------GetPivotTotalName-------------") | |
| return "AsposeGetPivotTotalName" | |
| } | |
| func (c *CustomPivotTableGlobalizationSettings) GetTextOfGrandTotal() string { | |
| fmt.Println("---------GetPivotGrandTotalName-------------") | |
| return "AsposeGetPivotGrandTotalName" | |
| } | |
| func (c *CustomPivotTableGlobalizationSettings) GetTextOfMultipleItems() string { | |
| fmt.Println("---------GetMultipleItemsName-------------") | |
| return "AsposeGetMultipleItemsName" | |
| } | |
| func (c *CustomPivotTableGlobalizationSettings) GetTextOfAll() string { | |
| fmt.Println("---------GetAllName-------------") | |
| return "AsposeGetAllName" | |
| } | |
| func (c *CustomPivotTableGlobalizationSettings) GetTextOfColumnLabels() string { | |
| fmt.Println("---------GetColumnLabelsOfPivotTable-------------") | |
| return "AsposeGetColumnLabelsOfPivotTable" | |
| } | |
| func (c *CustomPivotTableGlobalizationSettings) GetTextOfRowLabels() string { | |
| fmt.Println("---------GetRowLabelsNameOfPivotTable-------------") | |
| return "AsposeGetRowLabelsNameOfPivotTable" | |
| } | |
| func (c *CustomPivotTableGlobalizationSettings) GetTextOfEmptyData() string { | |
| fmt.Println("---------GetEmptyDataName-------------") | |
| return "(blank)AsposeGetEmptyDataName" | |
| } | |
| func (c *CustomPivotTableGlobalizationSettings) GetTextOfSubTotal(subTotalType PivotFieldSubtotalType) string { | |
| fmt.Println("---------GetSubTotalName-------------") | |
| switch subTotalType { | |
| case PivotFieldSubtotalType_Sum: | |
| return "AsposeSum" | |
| case PivotFieldSubtotalType_Count: | |
| return "AsposeCount" | |
| case PivotFieldSubtotalType_Average: | |
| return "AsposeAverage" | |
| case PivotFieldSubtotalType_Max: | |
| return "AsposeMax" | |
| case PivotFieldSubtotalType_Min: | |
| return "AsposeMin" | |
| case PivotFieldSubtotalType_Product: | |
| return "AsposeProduct" | |
| case PivotFieldSubtotalType_CountNums: | |
| return "AsposeCount" | |
| case PivotFieldSubtotalType_Stdev: | |
| return "AsposeStdDev" | |
| case PivotFieldSubtotalType_Stdevp: | |
| return "AsposeStdDevp" | |
| case PivotFieldSubtotalType_Var: | |
| return "AsposeVar" | |
| case PivotFieldSubtotalType_Varp: | |
| return "AsposeVarp" | |
| default: | |
| return "AsposeSubTotalName" | |
| } | |
| } | |
| func main() { | |
| srcDir := "../Data/01_SourceDirectory/" | |
| outDir := "../Data/02_OutputDirectory/" | |
| wb, _ := NewWorkbook_String(srcDir + "samplePivotTableGlobalizationSettings.xlsx") | |
| customSettings := &CustomPivotTableGlobalizationSettings{} | |
| settings, _ := wb.GetSettings() | |
| globalizationSettings, _ := settings.GetGlobalizationSettings() | |
| globalizationSettings.SetPivotSettings(&customSettings.PivotGlobalizationSettings) | |
| wss, _ := wb.GetWorksheets() | |
| ws1, _ := wss.Get_Int(0) | |
| ws1.SetIsVisible(false) | |
| ws2, _ := wss.Get_Int(1) | |
| pivotTables, _ := ws2.GetPivotTables() | |
| pt, _ := pivotTables.Get_Int(0) | |
| pt.RefreshData() | |
| pt.CalculateData() | |
| options := &PdfSaveOptions{} | |
| options.SetOnePagePerSheet(true) | |
| wb.Save_String(outDir + "outputPivotTableGlobalizationSettings.pdf") | |
| fmt.Println("Pivot table globalization settings applied successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func U16String(input string) string { | |
| // Assuming this function converts string to U16String. | |
| return input | |
| } | |
| func main() { | |
| wb, _ := NewWorkbook_String("..\\Data\\01_SourceDirectory\\aspose-sample.xlsx") | |
| fileContent, err := ioutil.ReadFile("..\\Data\\01_SourceDirectory\\CustomUI.xml") | |
| if err != nil { | |
| fmt.Println("Failed to open CustomUI.xml") | |
| return | |
| } | |
| ribbonXml := string(fileContent) | |
| xmlStr := U16String(ribbonXml) | |
| wb.SetRibbonXml(xmlStr) | |
| fmt.Println("Ribbon XML set successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Add a new worksheet to the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtain the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Add sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_Int(110) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(260) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(12) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(100) | |
| // Add a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Access the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Add NSeries (chart data source) to the chart ranging from "A1" cell to "B4" | |
| nseries, _ := chart.GetNSeries() | |
| nseries.Add_String_Bool("A1:B4", true) | |
| // Set the chart type of 2nd NSeries to display as line chart | |
| nseriesItem, _ := nseries.Get(1) | |
| nseriesItem.SetType(ChartType_Line) | |
| // Save the Excel file | |
| workbook.Save_String(outDir + "output.xls") | |
| fmt.Println("Chart created successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook object | |
| workbook, _ := NewWorkbook() | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Put the sample values used in a pie chart | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("C3") | |
| cell.PutValue_String("India") | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_String("China") | |
| cell, _ = cells.Get_String("C5") | |
| cell.PutValue_String("United States") | |
| cell, _ = cells.Get_String("C6") | |
| cell.PutValue_String("Russia") | |
| cell, _ = cells.Get_String("C7") | |
| cell.PutValue_String("United Kingdom") | |
| cell, _ = cells.Get_String("C8") | |
| cell.PutValue_String("Others") | |
| // Put the sample values used in a pie chart | |
| cell, _ = cells.Get_String("D2") | |
| cell.PutValue_String("% of world population") | |
| cell, _ = cells.Get_String("D3") | |
| cell.PutValue_Int(25) | |
| cell, _ = cells.Get_String("D4") | |
| cell.PutValue_Int(30) | |
| cell, _ = cells.Get_String("D5") | |
| cell.PutValue_Int(10) | |
| cell, _ = cells.Get_String("D6") | |
| cell.PutValue_Int(13) | |
| cell, _ = cells.Get_String("D7") | |
| cell.PutValue_Int(9) | |
| cell, _ = cells.Get_String("D8") | |
| cell.PutValue_Int(13) | |
| // Create a pie chart with desired length and width | |
| charts, _ := worksheet.GetCharts() | |
| pieIdx, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Pie, 1, 6, 15, 14) | |
| // Access the pie chart | |
| pie, _ := charts.Get_Int(pieIdx) | |
| // Set the pie chart series | |
| pieNSeries, _ := pie.GetNSeries() | |
| pieNSeries.Add_String_Bool("D3:D8", true) | |
| // Set the category data | |
| pieNSeries.SetCategoryData("=Sheet1!$C$3:$C$8") | |
| // Set the chart title that is linked to cell D2 | |
| pieTitle, _ := pie.GetTitle() | |
| pieTitle.SetLinkedSource("D2") | |
| // Set the legend position at the bottom | |
| pieLegend, _ := pie.GetLegend() | |
| pieLegend.SetPosition(LegendPositionType_Bottom) | |
| // Set the chart title's font name and color | |
| titleFont, _ := pieTitle.GetFont() | |
| titleFont.SetName("Calibri") | |
| titleFont.SetSize(18) | |
| // Access the chart series | |
| nSeries, _ := pie.GetNSeries() | |
| srs, _ := nSeries.Get(0) | |
| // Color the individual points with custom colors | |
| points, _ := srs.GetPoints() | |
| point, _ := points.Get(0) | |
| pointArea, _ := point.GetArea() | |
| color1, _ := NewColor() | |
| pointArea.SetForegroundColor(color1) | |
| point, _ = points.Get(1) | |
| pointArea, _ = point.GetArea() | |
| color2, _ := NewColor() | |
| pointArea.SetForegroundColor(color2) | |
| point, _ = points.Get(2) | |
| pointArea, _ = point.GetArea() | |
| color3, _ := NewColor() | |
| pointArea.SetForegroundColor(color3) | |
| point, _ = points.Get(3) | |
| pointArea, _ = point.GetArea() | |
| color4, _ := NewColor() | |
| pointArea.SetForegroundColor(color4) | |
| point, _ = points.Get(4) | |
| pointArea, _ = point.GetArea() | |
| color5, _ := NewColor() | |
| pointArea.SetForegroundColor(color5) | |
| point, _ = points.Get(5) | |
| pointArea, _ = point.GetArea() | |
| color6, _ := NewColor() | |
| pointArea.SetForegroundColor(color6) | |
| // Autofit all columns | |
| worksheet.AutoFitColumns() | |
| // Save the workbook | |
| outputPath := outDir + "output.out.xlsx" | |
| workbook.Save_String(outputPath) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load the workbook | |
| wb, _ := NewWorkbook_String(srcDir + "SamplePivotSort.xlsx") | |
| // Get the first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Get the pivot tables collection | |
| pivotTables, _ := sheet.GetPivotTables() | |
| // Source PivotTable | |
| // Add a PivotTable to the worksheet | |
| index, _ := pivotTables.Add_String_String_String("=Sheet1!A1:C10", "E3", "PivotTable2") | |
| // Access the instance of the newly added PivotTable | |
| pivotTable, _ := pivotTables.Get_Int(index) | |
| // Unshow grand totals for rows and columns | |
| pivotTable.SetShowRowGrandTotals(false) | |
| pivotTable.SetShowColumnGrandTotals(false) | |
| // Drag the first field to the row area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 1) | |
| rowFields, _ := pivotTable.GetRowFields() | |
| rowField, _ := rowFields.Get_Int(0) | |
| rowField.SetIsAutoSort(true) | |
| rowField.SetIsAscendSort(true) | |
| // Drag the second field to the column area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Column, 0) | |
| colFields, _ := pivotTable.GetColumnFields() | |
| colField, _ := colFields.Get_Int(0) | |
| colField.SetNumberFormat("dd/mm/yyyy") | |
| colField.SetIsAutoSort(true) | |
| colField.SetIsAscendSort(true) | |
| // Drag the third field to the data area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Data, 2) | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| // End of source PivotTable | |
| // Sort the PivotTable on "SeaFood" row field values | |
| // Add a PivotTable to the worksheet | |
| index, _ = pivotTables.Add_String_String_String("=Sheet1!A1:C10", "E10", "PivotTable2") | |
| // Access the instance of the newly added PivotTable | |
| pivotTable, _ = pivotTables.Get_Int(index) | |
| // Unshow grand totals for rows and columns | |
| pivotTable.SetShowRowGrandTotals(false) | |
| pivotTable.SetShowColumnGrandTotals(false) | |
| // Drag the first field to the row area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 1) | |
| rowFields, _ = pivotTable.GetRowFields() | |
| rowField, _ = rowFields.Get_Int(0) | |
| rowField.SetIsAutoSort(true) | |
| rowField.SetIsAscendSort(true) | |
| // Drag the second field to the column area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Column, 0) | |
| colFields, _ = pivotTable.GetColumnFields() | |
| colField, _ = colFields.Get_Int(0) | |
| colField.SetNumberFormat("dd/mm/yyyy") | |
| colField.SetIsAutoSort(true) | |
| colField.SetIsAscendSort(true) | |
| colField.SetAutoSortField(0) | |
| // Drag the third field to the data area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Data, 2) | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| // End of sort the PivotTable on "SeaFood" row field values | |
| // Sort the PivotTable on "28/07/2000" column field values | |
| // Add a PivotTable to the worksheet | |
| index, _ = pivotTables.Add_String_String_String("=Sheet1!A1:C10", "E18", "PivotTable2") | |
| // Access the instance of the newly added PivotTable | |
| pivotTable, _ = pivotTables.Get_Int(index) | |
| // Unshow grand totals for rows and columns | |
| pivotTable.SetShowRowGrandTotals(false) | |
| pivotTable.SetShowColumnGrandTotals(false) | |
| // Drag the first field to the row area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Row, 1) | |
| rowFields, _ = pivotTable.GetRowFields() | |
| rowField, _ = rowFields.Get_Int(0) | |
| rowField.SetIsAutoSort(true) | |
| rowField.SetIsAscendSort(true) | |
| rowField.SetAutoSortField(0) | |
| // Drag the second field to the column area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Column, 0) | |
| colFields, _ = pivotTable.GetColumnFields() | |
| colField, _ = colFields.Get_Int(0) | |
| colField.SetNumberFormat("dd/mm/yyyy") | |
| colField.SetIsAutoSort(true) | |
| colField.SetIsAscendSort(true) | |
| // Drag the third field to the data area | |
| pivotTable.AddFieldToArea_PivotFieldType_Int(PivotFieldType_Data, 2) | |
| pivotTable.RefreshData() | |
| pivotTable.CalculateData() | |
| // End of sort the PivotTable on "28/07/2000" column field values | |
| // Save the Excel file | |
| wb.Save_String(outDir + "out_java.xlsx") | |
| // Save as PDF | |
| options, _ := NewPdfSaveOptions() | |
| options.SetOnePagePerSheet(true) | |
| wb.Save_String_SaveOptions(outDir + "out_java.pdf", options.ToSaveOptions()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| wb, _ := NewWorkbook() | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_Int_Int(0, 2) | |
| cell.PutValue_Int(1) | |
| cell, _ = cells.Get_Int_Int(1, 2) | |
| cell.PutValue_Int(2) | |
| cell, _ = cells.Get_Int_Int(2, 2) | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_Int_Int(2, 3) | |
| cell.PutValue_Int(4) | |
| namedRange, _ := cells.CreateRange_Int_Int_Int_Int(0, 2, 3, 1) | |
| namedRange.SetName("NamedRange") | |
| cut, _ := cells.CreateRange_String("C:C") | |
| cells.InsertCutCells(cut, 0, 1, ShiftType_Right) | |
| wb.Save_String(outDir + "CutAndPasteCells.xlsx") | |
| fmt.Println("Cells cut and pasted successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiating a Workbook object | |
| workbook, _ := NewWorkbook_String(srcDir + "ColouredCells.xlsx") | |
| // Instantiating a CellsColor object for foreground color | |
| clrForeground, _ := workbook.CreateCellsColor() | |
| colorRed, _ := Color_Red() | |
| clrForeground.SetColor(colorRed) | |
| // Instantiating a CellsColor object for background color | |
| clrBackground, _ := workbook.CreateCellsColor() | |
| colorWhite, _ := Color_White() | |
| clrBackground.SetColor(colorWhite) | |
| // Accessing the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Call AddFillColorFilter function to apply the filter | |
| autoFilter, _ := worksheet.GetAutoFilter() | |
| autoFilter.AddFillColorFilter(0, BackgroundType_Solid, clrForeground, clrBackground) | |
| // Call refresh function to update the worksheet | |
| autoFilter.Refresh() | |
| // Saving the modified Excel file | |
| workbook.Save_String(outDir + "FilteredColouredCells.xlsx") | |
| fmt.Println("Filter applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := "..\\Data\\01_SourceDirectory\\" + "Date.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "FilteredDate.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Call AddDateFilter function to apply the filter | |
| autoFilter, _ := worksheet.GetAutoFilter() | |
| autoFilter.AddDateFilter(0, DateTimeGroupingType_Month, 2018, 1, 0, 0, 0, 0) | |
| // Call refresh function to update the worksheet | |
| autoFilter.Refresh() | |
| // Save the modified Excel file | |
| workbook.Save_String_SaveOptions(outputFilePath, nil) | |
| fmt.Println("Date filter applied and file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "Date.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "FilteredDynamicDate.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Accessing the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Call DynamicFilter function to apply the filter | |
| autoFilter, _ := worksheet.GetAutoFilter() | |
| autoFilter.Dynamic_Filter(0, DynamicFilterType_January) | |
| // Call refresh function to update the worksheet | |
| autoFilter.Refresh() | |
| // Save the modified Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Dynamic filter applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "Text.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "FilteredText.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Call Filter function to apply the filter | |
| autoFilter, _ := worksheet.GetAutoFilter() | |
| autoFilter.Filter(0, "Angola") | |
| // Call refresh function to update the worksheet | |
| autoFilter.Refresh() | |
| // Save the modified Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Filter applied and file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiating a Workbook object | |
| workbook, _ := NewWorkbook_String(srcDir + "Blank.xlsx") | |
| // Accessing the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Call MatchBlanks function to apply the filter | |
| autoFilter, _ := worksheet.GetAutoFilter() | |
| autoFilter.MatchBlanks(0) | |
| // Call refresh function to update the worksheet | |
| autoFilter.Refresh() | |
| // Saving the modified Excel file | |
| workbook.Save_String(outDir + "FilteredBlank.xlsx") | |
| fmt.Println("Filter applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook object and open the Excel file | |
| workbook, _ := NewWorkbook_String(srcDir + "Blank.xlsx") | |
| // Access the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Call MatchNonBlanks function to apply the filter | |
| autoFilter, _ := worksheet.GetAutoFilter() | |
| autoFilter.MatchNonBlanks(0) | |
| // Call refresh function to update the worksheet | |
| autoFilter.Refresh() | |
| // Save the modified Excel file | |
| workbook.Save_String(outDir + "FilteredNonBlank.xlsx") | |
| fmt.Println("Non-blank filter applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "sourseSampleCountryNames.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "outSourseSampleCountryNames.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Accessing the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Creating AutoFilter by giving the cells range | |
| autoFilter, _ := worksheet.GetAutoFilter() | |
| autoFilter.SetRange_String("A1:A18") | |
| // Initialize filter for rows containing string "Ba" | |
| autoFilter.Filter(0, "Ba") | |
| // Refresh the filter to show/hide filtered rows | |
| autoFilter.Refresh() | |
| // Saving the modified Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("AutoFilter applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "book1.xls" | |
| // Path of output excel file | |
| outputFilePath := outDir + "output.out.xls" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Accessing the first worksheet in the Excel file | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Creating AutoFilter by giving the cells range of the heading row | |
| autoFilter, _ := worksheet.GetAutoFilter() | |
| autoFilter.SetRange_String("A1:B1") | |
| // Save the modified Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("AutoFilter applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Load the workbook | |
| workbook, _ := NewWorkbook_String(srcDir + "NonPrimitiveShape.xlsx") | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Accessing the user defined shape | |
| shapes, _ := worksheet.GetShapes() | |
| shape, _ := shapes.Get_Int(0) | |
| autoShapeType, _ := shape.GetAutoShapeType() | |
| if autoShapeType == AutoShapeType_NotPrimitive { | |
| // Access shape's data | |
| shapePathCollection, _ := shape.GetPaths() | |
| // Access information of individual path | |
| count, _ := shapePathCollection.GetCount() | |
| for i := int32(0); i < count; i++ { | |
| shapePath, _ := shapePathCollection.Get(i) | |
| // Access path segment list | |
| pathSegments, _ := shapePath.GetPathSegementList() | |
| // Access individual path segment | |
| segmentCount, _ := pathSegments.GetCount() | |
| for j := int32(0); j < segmentCount; j++ { | |
| pathSegment, _ := pathSegments.Get(j) | |
| // Gets the points in path segment | |
| segmentPoints, _ := pathSegment.GetPoints() | |
| pointCount, _ := segmentPoints.GetCount() | |
| for k := int32(0); k < pointCount; k++ { | |
| pathPoint, _ := segmentPoints.Get(k) | |
| x, _ := pathPoint.GetXAngle() | |
| y, _ := pathPoint.GetYAngle() | |
| fmt.Printf("X: %f, Y: %f\n", x, y) | |
| } | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Instantiating a Workbook object | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Workbook object | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Adding sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(150) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(60) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(32) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| // Adding a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Accessing the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
| seriesCollection, _ := chart.GetNSeries() | |
| seriesCollection.Add_String_Bool("A1:B3", true) | |
| // Show value labels | |
| series0, _ := seriesCollection.Get(0) | |
| dataLabels0, _ := series0.GetDataLabels() | |
| dataLabels0.SetShowValue(true) | |
| // Show series name labels | |
| series1, _ := seriesCollection.Get(1) | |
| dataLabels1, _ := series1.GetDataLabels() | |
| dataLabels1.SetShowSeriesName(true) | |
| // Move labels to center | |
| dataLabels1.SetPosition(LabelPositionType_Center) | |
| // Save the file | |
| workbook.Save_String("chart_datalabels.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "CellsNet46500.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "outputSortData_CustomSortList.xlsx" | |
| // Create a workbook object and load template file | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Instantiate data sorter object | |
| sorter, _ := wb.GetDataSorter() | |
| // Add key for second column for red color | |
| redColor, _ := Color_FromArgb(255) // Using single int32 value for color | |
| sorter.AddColorKey(1, SortOnType_CellColor, SortOrder_Descending, redColor) | |
| // Sort the data based on the key | |
| wss, _ := wb.GetWorksheets() | |
| _, _ = wss.Get_Int(0) // Avoid unused variable warning | |
| sorter.Sort() | |
| // Save the output file | |
| wb.Save_String(outputFilePath) | |
| fmt.Println("Data sorted successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "book1.xls" | |
| // Path of output excel file | |
| outputFilePath := outDir + "output.out.xls" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Get the workbook datasorter object | |
| sorter, _ := workbook.GetDataSorter() | |
| // Set the first order for datasorter object | |
| sorter.SetOrder1(SortOrder_Descending) | |
| // Define the first key | |
| sorter.SetKey1(0) | |
| // Set the second order for datasorter object | |
| sorter.SetOrder2(SortOrder_Ascending) | |
| // Get the worksheets and first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| _ , _ = wss.Get_Int(0) | |
| // Sort data in the specified data range (A1:B14) | |
| sorter.Sort() | |
| // Save the excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Data sorted successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "../Data/02_OutputDirectory/" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Add a new worksheet to the workbook | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Get the reference of the newly added worksheet | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Add sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(10) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_Int(170) | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_Int(200) | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_Int(120) | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(320) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(40) | |
| // Add sample values to cells as category data | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("Q1") | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_String("Q2") | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_String("Y1") | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_String("Y2") | |
| // Add a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Access the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Add SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B4" | |
| nSeries, _ := chart.GetNSeries() | |
| nSeries.Add_String_Bool("A1:B4", true) | |
| // Set the data source for the category data of SeriesCollection | |
| nSeries.SetCategoryData("C1:C4") | |
| // Save the Excel file | |
| workbook.Save_String(outDir + "output.xls") | |
| fmt.Println("Chart added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Instantiating a Workbook object | |
| workbook, _ := NewWorkbook() | |
| // Adding a new worksheet to the Excel object | |
| wss, _ := workbook.GetWorksheets() | |
| sheetIndex, _ := wss.Add() | |
| // Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet, _ := wss.Get_Int(sheetIndex) | |
| // Adding sample values to cells | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_Int_Int(0, 0) // Getting cell A1 | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_Int_Int(1, 0) // Getting cell A2 | |
| cell.PutValue_Int(100) | |
| cell, _ = cells.Get_Int_Int(2, 0) // Getting cell A3 | |
| cell.PutValue_Int(170) | |
| cell, _ = cells.Get_Int_Int(3, 0) // Getting cell A4 | |
| cell.PutValue_Int(300) | |
| cell, _ = cells.Get_Int_Int(0, 1) // Getting cell B1 | |
| cell.PutValue_Int(160) | |
| cell, _ = cells.Get_Int_Int(1, 1) // Getting cell B2 | |
| cell.PutValue_Int(32) | |
| cell, _ = cells.Get_Int_Int(2, 1) // Getting cell B3 | |
| cell.PutValue_Int(50) | |
| cell, _ = cells.Get_Int_Int(3, 1) // Getting cell B4 | |
| cell.PutValue_Int(40) | |
| // Adding sample values to cells as category data | |
| cell, _ = cells.Get_Int_Int(0, 2) // Getting cell C1 | |
| cell.PutValue_String("Q1") | |
| cell, _ = cells.Get_Int_Int(1, 2) // Getting cell C2 | |
| cell.PutValue_String("Q2") | |
| cell, _ = cells.Get_Int_Int(2, 2) // Getting cell C3 | |
| cell.PutValue_String("Y1") | |
| cell, _ = cells.Get_Int_Int(3, 2) // Getting cell C4 | |
| cell.PutValue_String("Y2") | |
| // Adding a chart to the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chartIndex, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 5, 0, 15, 5) | |
| // Accessing the instance of the newly added chart | |
| chart, _ := charts.Get_Int(chartIndex) | |
| // Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B4" | |
| seriesCollection, _ := chart.GetNSeries() | |
| seriesCollection.Add_String_Bool("A1:B4", true) | |
| // Saving the Excel file | |
| workbook.Save_String(outDir + "output.xls") | |
| fmt.Println("Chart added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook object | |
| workbook, _ := NewWorkbook() | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet1, _ := wss.Get_Int(0) | |
| // Add a new worksheet and access it | |
| index, _ := wss.Add() | |
| worksheet2, _ := wss.Get_Int(index) | |
| // Create a range in the second worksheet | |
| cells, _ := worksheet2.GetCells() | |
| range_, _ := cells.CreateRange_String_String("E1", "E4") | |
| // Name the range | |
| range_.SetName("MyRange") | |
| // Fill different cells with data in the range | |
| cell1, _ := range_.Get(0, 0) | |
| cell1.PutValue_String("Blue") | |
| cell2, _ := range_.Get(1, 0) | |
| cell2.PutValue_String("Red") | |
| cell3, _ := range_.Get(2, 0) | |
| cell3.PutValue_String("Green") | |
| cell4, _ := range_.Get(3, 0) | |
| cell4.PutValue_String("Yellow") | |
| // Get the validations collection | |
| validations, _ := worksheet1.GetValidations() | |
| // Create Cell Area | |
| ca, _ := NewCellArea() | |
| // Create a new validation to the validations list | |
| validationIndex, _ := validations.Add(ca) | |
| validation, _ := validations.Get(validationIndex) | |
| // Set the validation type | |
| validation.SetType(ValidationType_List) | |
| // Set the operator | |
| validation.SetOperator(OperatorType_None) | |
| // Set the in cell drop down | |
| validation.SetInCellDropDown(true) | |
| // Set the formula1 | |
| validation.SetFormula1_String("=MyRange") | |
| // Enable it to show error | |
| validation.SetShowError(true) | |
| // Set the alert type severity level | |
| validation.SetAlertStyle(ValidationAlertType_Stop) | |
| // Set the error title | |
| validation.SetErrorTitle("Error") | |
| // Set the error message | |
| validation.SetErrorMessage("Please select a color from the list") | |
| // Save the Excel file | |
| wbSavePath := outDir + "output.out.xls" | |
| workbook.Save_String(wbSavePath) | |
| fmt.Println("File saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook | |
| workbook, _ := NewWorkbook() | |
| // Obtain the cells of the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Put a string value into the A1 cell | |
| cell, _ := cells.Get_Int_Int(0, 0) | |
| cell.PutValue_String("Please enter Date b/w 1/1/1970 and 12/31/1999") | |
| // Set row height and column width for the cells | |
| cells.SetRowHeight(0, 31) | |
| cells.SetColumnWidth(0, 35) | |
| // Get the validations collection | |
| validations, _ := ws.GetValidations() | |
| // Create Cell Area | |
| ca, _ := CellArea_CreateCellArea_Int_Int_Int_Int(0, 0, 0, 0) | |
| // Add a new validation | |
| validationIndex, _ := validations.Add(ca) | |
| validation, _ := validations.Get(validationIndex) | |
| // Set the data validation type | |
| validation.SetType(ValidationType_Date) | |
| // Set the operator for the data validation | |
| validation.SetOperator(OperatorType_Between) | |
| // Set the value or expression associated with the data validation | |
| validation.SetFormula1_String("1/1/1970") | |
| // The value or expression associated with the second part of the data validation | |
| validation.SetFormula2_String("12/31/1999") | |
| // Enable the error | |
| validation.SetShowError(true) | |
| // Set the validation alert style | |
| validation.SetAlertStyle(ValidationAlertType_Stop) | |
| // Set the title of the data-validation error dialog box | |
| validation.SetErrorTitle("Date Error") | |
| // Set the data validation error message | |
| validation.SetErrorMessage("Enter a Valid Date") | |
| // Set and enable the data validation input message | |
| validation.SetInputMessage("Date Validation Type") | |
| validation.SetIgnoreBlank(true) | |
| validation.SetShowInput(true) | |
| // Set a collection of CellArea which contains the data validation settings | |
| cellArea, _ := CellArea_CreateCellArea_Int_Int_Int_Int(0, 0, 1, 1) | |
| // Add the validation area - creating a slice for areas | |
| areas, _ := validation.GetAreas() | |
| areas = append(areas, *cellArea) | |
| // Save the Excel file | |
| outputPath := outDir + "output.out.xls" | |
| workbook.Save_String(outputPath) | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook | |
| workbook, _ := NewWorkbook() | |
| // Obtain the cells of the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Put a string value into A1 cell | |
| cellA1, _ := cells.Get_String("A1") | |
| cellA1.PutValue_String("Please enter Time b/w 09:00 and 11:30 'o Clock") | |
| // Set the row height and column width for the cells | |
| cells.SetRowHeight(0, 31) | |
| cells.SetColumnWidth(0, 35) | |
| // Get the validations collection | |
| validations, _ := ws.GetValidations() | |
| // Create Cell Area | |
| ca, _ := NewCellArea() | |
| // Add a new validation | |
| validationIdx, _ := validations.Add(ca) | |
| validation, _ := validations.Get(validationIdx) | |
| // Set the data validation type | |
| validation.SetType(ValidationType_Time) | |
| // Set the operator for the data validation | |
| validation.SetOperator(OperatorType_Between) | |
| // Set the value or expression associated with the data validation | |
| validation.SetFormula1_String("09:00") | |
| // The value or expression associated with the second part of the data validation | |
| validation.SetFormula2_String("11:30") | |
| // Enable the error | |
| validation.SetShowError(true) | |
| // Set the validation alert style | |
| validation.SetAlertStyle(ValidationAlertType_Information) | |
| // Set the title of the data-validation error dialog box | |
| validation.SetErrorTitle("Time Error") | |
| // Set the data validation error message | |
| validation.SetErrorMessage("Enter a Valid Time") | |
| // Set and enable the data validation input message | |
| validation.SetInputMessage("Time Validation Type") | |
| validation.SetIgnoreBlank(true) | |
| validation.SetShowInput(true) | |
| // Save the Excel file | |
| workbook.Save_String(outDir + "output.out.xls") | |
| fmt.Println("File saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Obtain the cells of the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Put a string value into A1 cell | |
| cellA1, _ := cells.Get_Int_Int(0, 0) | |
| cellA1.PutValue_String("Please enter a string not more than 5 chars") | |
| // Set row height and column width for the cell | |
| cells.SetRowHeight(0, 31) | |
| cells.SetColumnWidth(0, 35) | |
| // Get the validations collection | |
| validations, _ := ws.GetValidations() | |
| // Create Cell Area | |
| ca, _ := NewCellArea() | |
| // Add a new validation | |
| validationIndex, _ := validations.Add(ca) | |
| validation, _ := validations.Get(validationIndex) | |
| // Set the data validation type | |
| validation.SetType(ValidationType_TextLength) | |
| // Set the operator for the data validation | |
| validation.SetOperator(OperatorType_LessOrEqual) | |
| // Set the value or expression associated with the data validation | |
| validation.SetFormula1_String("5") | |
| // Enable the error | |
| validation.SetShowError(true) | |
| // Set the validation alert style | |
| validation.SetAlertStyle(ValidationAlertType_Warning) | |
| // Set the title of the data-validation error dialog box | |
| validation.SetErrorTitle("Text Length Error") | |
| // Set the data validation error message | |
| validation.SetErrorMessage(" Enter a Valid String") | |
| // Set and enable the data validation input message | |
| validation.SetInputMessage("TextLength Validation Type") | |
| validation.SetIgnoreBlank(true) | |
| validation.SetShowInput(true) | |
| // Instead of SetArea, use SetArea for validation | |
| validation.SetFormula1_String("5") // Setting a valid formula | |
| // Save the Excel file | |
| outputPath := outDir + "output.out.xls" | |
| workbook.Save_String(outputPath) | |
| fmt.Printf("File saved successfully: %s\n", outputPath) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "sample.xlsx" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access Cell C1 | |
| // Cell C1 has the Decimal Validation applied on it. | |
| // It can take only the values Between 10 and 20 | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("C1") | |
| // Enter 3 inside this cell | |
| // Since it is not between 10 and 20, it should fail the validation | |
| cell.PutValue_Int(3) | |
| // Check if number 3 satisfies the Data Validation rule applied on this cell | |
| validationValue, _ := cell.GetValidationValue() | |
| fmt.Println("Is 3 a Valid Value for this Cell:", validationValue) | |
| // Enter 15 inside this cell | |
| // Since it is between 10 and 20, it should succeed the validation | |
| cell.PutValue_Int(15) | |
| // Check if number 15 satisfies the Data Validation rule applied on this cell | |
| validationValue, _ = cell.GetValidationValue() | |
| fmt.Println("Is 15 a Valid Value for this Cell:", validationValue) | |
| // Enter 30 inside this cell | |
| // Since it is not between 10 and 20, it should fail the validation again | |
| cell.PutValue_Int(30) | |
| // Check if number 30 satisfies the Data Validation rule applied on this cell | |
| validationValue, _ = cell.GetValidationValue() | |
| fmt.Println("Is 30 a Valid Value for this Cell:", validationValue) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "sampleValidation.xlsx" | |
| // Create workbook | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Get worksheet | |
| wss, _ := wb.GetWorksheets() | |
| sheet, _ := wss.Get_String("Sheet1") | |
| // Get cells collection | |
| cells, _ := sheet.GetCells() | |
| // Check validation for cell A2 | |
| a2, _ := cells.Get_String("A2") | |
| va2, _ := a2.GetValidation() | |
| if inCellDropDown, _ := va2.GetInCellDropDown(); inCellDropDown { | |
| fmt.Println("A2 is a dropdown") | |
| } else { | |
| fmt.Println("A2 is NOT a dropdown") | |
| } | |
| // Check validation for cell B2 | |
| b2, _ := cells.Get_String("B2") | |
| vb2, _ := b2.GetValidation() | |
| if inCellDropDown, _ := vb2.GetInCellDropDown(); inCellDropDown { | |
| fmt.Println("B2 is a dropdown") | |
| } else { | |
| fmt.Println("B2 is NOT a dropdown") | |
| } | |
| // Check validation for cell C2 | |
| c2, _ := cells.Get_String("C2") | |
| vc2, _ := c2.GetValidation() | |
| if inCellDropDown, _ := vc2.GetInCellDropDown(); inCellDropDown { | |
| fmt.Println("C2 is a dropdown") | |
| } else { | |
| fmt.Println("C2 is NOT a dropdown") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source and output directory paths | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load the workbook | |
| workbook, _ := NewWorkbook_String(srcDir + "ValidationsSample.xlsx") | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Accessing the Validations collection of the worksheet | |
| validations, _ := worksheet.GetValidations() | |
| validation, _ := validations.Get(0) | |
| // Create cell area | |
| cellArea, _ := NewCellArea() | |
| // Adding the cell area to Validation | |
| validation.AddArea_CellArea(cellArea) | |
| // Save the output workbook | |
| workbook.Save_String(outDir + "ValidationsSample_out.xlsx") | |
| fmt.Println("Validation added successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create a workbook object | |
| workbook, _ := NewWorkbook() | |
| // Create a worksheet and get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Accessing the Validations collection of the worksheet | |
| validations, _ := ws.GetValidations() | |
| // Create Cell Area | |
| ca, _ := NewCellArea() | |
| ca.Set_StartRow(0) | |
| ca.Set_EndRow(0) | |
| ca.Set_StartColumn(0) | |
| ca.Set_EndColumn(0) | |
| // Creating a Validation object | |
| validationIndex, _ := validations.Add(ca) | |
| validation, _ := validations.Get(validationIndex) | |
| // Setting the validation type to whole number | |
| validation.SetType(ValidationType_WholeNumber) | |
| // Setting the operator for validation to Between | |
| validation.SetOperator(OperatorType_Between) | |
| // Setting the minimum value for the validation | |
| validation.SetFormula1_String("10") | |
| // Setting the maximum value for the validation | |
| validation.SetFormula2_String("1000") | |
| // Applying the validation to a range of cells from A1 to B2 using the CellArea structure | |
| area, _ := NewCellArea() | |
| area.Set_StartRow(0) | |
| area.Set_EndRow(1) | |
| area.Set_StartColumn(0) | |
| area.Set_EndColumn(1) | |
| // Adding the cell area to Validation | |
| validation.AddArea_CellArea(area) | |
| // Save the workbook | |
| workbook.Save_String(outDir + "output.out.xls") | |
| fmt.Println("Validation applied successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create a new workbook | |
| workbook, _ := NewWorkbook() | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access the cell where you want to apply the date format | |
| cells, _ := ws.GetCells() | |
| a1, _ := cells.Get_String("A1") | |
| // Set a numeric value that represents a date (e.g., 44210 represents 09/06/2021 in Excel) | |
| a1.PutValue_Int(44210) | |
| // Create a style object to apply the date format | |
| a1Style, _ := a1.GetStyle() | |
| // "14" represents a standard date format in Excel (MM/DD/YYYY) | |
| a1Style.SetNumber(14) | |
| // Apply the style to the cell | |
| a1.SetStyle_Style(a1Style) | |
| // Access the cell where you want to apply the currency format | |
| a2, _ := cells.Get_String("A2") | |
| // Set a numeric value to the cell | |
| a2.PutValue_Int(44210) | |
| // Create a style object to apply the date format | |
| a2Style, _ := a2.GetStyle() | |
| // Custom format for YYYY-MM-DD | |
| a2Style.SetCustom_String("YYYY-MM-DD") | |
| // Apply the style to the cell | |
| a2.SetStyle_Style(a2Style) | |
| // Save the workbook | |
| workbook.Save_String("DateFormatted.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| inputFilePath := "sampleAccessAndModifyLabelOfOleObject.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Save workbook to memory stream | |
| ms, _ := wb.SaveToStream() | |
| // Load workbook from memory stream | |
| wb, _ = NewWorkbook_Stream(ms) | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Put some integer values in cell A1 and A2 | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.PutValue_Int(45253) | |
| cell, _ = cells.Get_String("A2") | |
| cell.PutValue_Int(43791) | |
| // Save the workbook | |
| wb.Save_String("output_out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| a1, _ := cells.Get_String("A1") | |
| date1 := time.Date(2023, time.May, 15, 0, 0, 0, 0, time.UTC) | |
| a1.PutValue_Date(date1) | |
| cellType, _ := a1.GetType() | |
| if cellType == CellValueType_IsNumeric { | |
| numericValue, _ := a1.IsNumericValue() | |
| fmt.Printf("A1 is Numeric Value: %v\n", numericValue) | |
| } | |
| a1Style, _ := a1.GetStyle() | |
| a1Style.SetCustom_String_Bool("mm-dd-yy hh:mm:ss", true) | |
| cellType, _ = a1.GetType() | |
| if cellType == CellValueType_IsDateTime { | |
| fmt.Println("Cell A1 contains a DateTime value.") | |
| _, _ = a1.GetDateTimeValue() // Removed unused variable | |
| stringValue, _ := a1.GetStringValue() | |
| fmt.Printf("A1 DateTime String Value: %s\n", stringValue) | |
| } else { | |
| fmt.Println("Cell A1 does not contain a DateTime value.") | |
| } | |
| a2, _ := cells.Get_String("A2") | |
| date2 := time.Date(2023, time.May, 16, 0, 0, 0, 0, time.UTC) | |
| a2.PutValue_Date(date2) | |
| cellType, _ = a2.GetType() | |
| if cellType == CellValueType_IsNumeric { | |
| numericValue, _ := a2.IsNumericValue() | |
| fmt.Printf("A2 is Numeric Value: %v\n", numericValue) | |
| } | |
| a2Style, _ := a2.GetStyle() | |
| a2Style.SetNumber(22) | |
| cellType, _ = a2.GetType() | |
| if cellType == CellValueType_IsDateTime { | |
| fmt.Println("Cell A2 contains a DateTime value.") | |
| _, _ = a2.GetDateTimeValue() // Removed unused variable | |
| stringValue, _ := a2.GetStringValue() | |
| fmt.Printf("A2 DateTime String Value: %s\n", stringValue) | |
| } else { | |
| fmt.Println("Cell A2 does not contain a DateTime value.") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| inputFilePath := "sampleAccessAndModifyLabelOfOleObject.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access cells | |
| cells, _ := ws.GetCells() | |
| // Process Cell A1 | |
| cellA1, _ := cells.Get_String("A1") | |
| cellA1.PutValue_Int(11) | |
| cellA1.PutValue_String("11-23-23 17:59:09") | |
| // Process Cell A2 | |
| cellA2, _ := cells.Get_String("A2") | |
| cellA2.PutValue_Int(11) | |
| cellA2.PutValue_String("11/23/2023 17:59") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook() | |
| workbookSettings, _ := workbook.GetSettings() | |
| workbookSettings.SetDate1904(false) | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| cellA1, _ := cells.Get_String("A1") | |
| cellA1.PutValue_Double(45237.0) | |
| cellA1Type, _ := cellA1.GetType() | |
| if cellA1Type == CellValueType_IsNumeric { | |
| value, _ := cellA1.GetDoubleValue() | |
| fmt.Printf("A1 is Numeric Value: %f\n", value) | |
| } | |
| workbookSettings.SetDate1904(true) | |
| fmt.Println("use The 1904 date system====================") | |
| cellA2, _ := cells.Get_String("A2") | |
| cellA2.PutValue_Double(43775.0) | |
| cellA2Type, _ := cellA2.GetType() | |
| if cellA2Type == CellValueType_IsNumeric { | |
| value, _ := cellA2.GetDoubleValue() | |
| fmt.Printf("A2 is Numeric Value: %f\n", value) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func TestCalcTimeRecursive(rec bool) { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| wb, _ := NewWorkbook_String(srcDir + "sample.xlsx") | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| opts, _ := NewCalculationOptions() // Fixed the number of return values | |
| opts.SetRecursive(rec) | |
| start := time.Now() | |
| for i := int32(0); i < 1000000; i++ { | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| cell.Calculate(opts) | |
| } | |
| stop := time.Now() | |
| duration := stop.Sub(start) | |
| estimatedTime := duration.Milliseconds() / 1000 | |
| fmt.Printf("Recursive %v: %v seconds\n", rec, estimatedTime) | |
| } | |
| func main() { | |
| TestCalcTimeRecursive(true) | |
| TestCalcTimeRecursive(false) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func TestCalcTimeRecursive(isRecursive bool) { | |
| workbook, _ := NewWorkbook() | |
| options, _ := NewCalculationOptions() | |
| options.SetRecursive(isRecursive) | |
| start := time.Now() | |
| workbook.CalculateFormula() // Fixed: Removed arguments as per the error message | |
| duration := time.Since(start).Milliseconds() | |
| fmt.Printf("Time (recursive=%v): %v ms\n", isRecursive, duration) | |
| } | |
| func main() { | |
| TestCalcTimeRecursive(true) | |
| TestCalcTimeRecursive(false) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "SampleInput.xlsx" | |
| // Create a smart pointer to a new Workbook instance | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Create a Worksheets object with reference to the sheets of the Workbook | |
| wss, _ := wb.GetWorksheets() | |
| // Get the first Worksheet from WorksheetCollection | |
| ws, _ := wss.Get_Int(0) | |
| // Delete the blank columns from the worksheet | |
| cells, _ := ws.GetCells() | |
| cells.DeleteBlankColumns() | |
| // Save the excel file | |
| outputFilePath := srcDir + "mybook.out.xlsx" | |
| wb.Save_String(outputFilePath) | |
| fmt.Println("Blank columns deleted successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open an existing Excel file | |
| inputFilePath := srcDir + "SampleInput.xlsx" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Create a Worksheets object with reference to the sheets of the Workbook | |
| sheets, _ := workbook.GetWorksheets() | |
| // Get the first Worksheet from WorksheetCollection | |
| sheet, _ := sheets.Get_Int(0) | |
| // Delete the Blank Rows from the worksheet | |
| cells, _ := sheet.GetCells() | |
| cells.DeleteBlankRows() | |
| // Save the Excel file | |
| outputFilePath := outDir + "mybook.out.xlsx" | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Blank rows deleted and workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("sampleInsertingDeletingRowsAndColumns.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| cells, _ := worksheet.GetCells() | |
| cells.DeleteColumn_Int(1) | |
| workbook.Save_String("sampleInsertingDeletingRowsAndColumns.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "Book1.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "Book2.xlsx" | |
| // Instantiate a new Workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Get all the worksheets in the book | |
| worksheets, _ := workbook.GetWorksheets() | |
| // Delete some defined names | |
| namesToRemove := []string{"NamedRange1", "NamedRange2"} | |
| names, _ := worksheets.GetNames() | |
| for _, name := range namesToRemove { | |
| names.Remove_String(name) | |
| } | |
| // Save the workbook to retain the changes | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Named ranges removed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "Book1.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "Book2.xlsx" | |
| // Instantiate a new Workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Get all the worksheets in the book | |
| worksheets, _ := workbook.GetWorksheets() | |
| // Delete some defined names | |
| names, _ := worksheets.GetNames() | |
| names.RemoveDuplicateNames() | |
| // Save the workbook to retain the changes | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Workbook saved successfully after removing duplicate names!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "Book1.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "Book2.xlsx" | |
| // Instantiate a new Workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Get all the worksheets in the book | |
| worksheets, _ := workbook.GetWorksheets() | |
| // Delete a named range by text | |
| names, _ := worksheets.GetNames() | |
| names.Remove_String("NamedRange") | |
| // Delete a defined name by index | |
| names.RemoveAt(0) | |
| // Save the workbook to retain the changes | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Named ranges removed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "source.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "output_out.xlsx" | |
| // Create workbook object from source Excel file | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the first pivot table object | |
| pivotTables, _ := worksheet.GetPivotTables() | |
| pivotTable, _ := pivotTables.Get_Int(0) | |
| // Remove pivot table using pivot table object | |
| pivotTables.Remove_PivotTable(pivotTable) | |
| // OR you can remove pivot table using pivot table position by uncommenting below line | |
| // pivotTables.RemoveAt(0) | |
| // Save the workbook | |
| wb.Save_String(outputFilePath) | |
| fmt.Println("Pivot table removed successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Instantiate a new Workbook. | |
| workbook, _ := NewWorkbook() | |
| // Get all the worksheets in the book. | |
| wss, _ := workbook.GetWorksheets() | |
| // Get the first worksheet in the worksheets collection. | |
| ws, _ := wss.Get_Int(0) | |
| // Gets cells. | |
| cells, _ := ws.GetCells() | |
| // Input some data with some formatting into a few cells in the range. | |
| cellC2, _ := cells.Get_String("C2") | |
| cellC2.PutValue_String("C2") | |
| cellC3, _ := cells.Get_String("C3") | |
| cellC3.PutValue_String("C3") | |
| ca, _ := CellArea_CreateCellArea_Int_Int_Int_Int(1, 1, 2, 2) | |
| // Delete the specified range of cells and shift cells to the left. | |
| startRow, _ := ca.Get_StartRow() | |
| startColumn, _ := ca.Get_StartColumn() | |
| endRow, _ := ca.Get_EndRow() | |
| endColumn, _ := ca.Get_EndColumn() | |
| cells.DeleteRange(startRow, startColumn, endRow, endColumn, ShiftType_Left) | |
| // Check if the value in B2 is equal to "C2". | |
| resultCell, _ := cells.Get_String("B2") | |
| strValue, _ := resultCell.GetStringValue() | |
| fmt.Println(strValue == "C2") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| html := "<html> <body> <table> <tr> <td> <br> This is sample data <br> This is sample data<br> This is sample data</td> </tr> </table> </body> </html>" | |
| var byteArray []uint8 | |
| for i := 0; i < len(html); i++ { | |
| c := html[i] | |
| if c <= 0x7F { | |
| byteArray = append(byteArray, c) | |
| } | |
| } | |
| loadOptions, _ := NewHtmlLoadOptions() | |
| loadOptions.SetDeleteRedundantSpaces(true) | |
| data := createByteArray(byteArray) | |
| workbook, _ := NewWorkbook_Stream(data) | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| ws.AutoFitColumns() | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| workbook.Save_String_SaveFormat(outDir+"outputDeleteRedundantSpacesWhileImportingFromHtml.xlsx", SaveFormat_Xlsx) | |
| fmt.Println("File saved successfully.") | |
| } | |
| func createByteArray(input []uint8) []uint8 { | |
| // Convert input to a byte array (same type) | |
| return input | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func GetDataFromFile(file string) ([]byte, error) { | |
| // open a file | |
| fileStream, err := ioutil.ReadFile(file) | |
| if err != nil { | |
| fmt.Println("Failed to open the file.") | |
| return nil, err | |
| } | |
| return fileStream, nil | |
| } | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| filename := srcDir + "encryptedBook1.out.tmp" | |
| fileStream, err := GetDataFromFile(filename) | |
| if err != nil { | |
| return | |
| } | |
| fileFormatInfo, _ := FileFormatUtil_DetectFileFormat_Stream_String(fileStream, "1234") | |
| fileFormatType, _ := fileFormatInfo.GetFileFormatType() | |
| fmt.Printf("File Format: %d\n", int(fileFormatType)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| inputFilePath := "LinkTypes.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| wss, _ := wb.GetWorksheets() | |
| _, _ = wss.Get_Int(0) | |
| // Accessing different types of links in the workbook | |
| // FilePath Links | |
| filePathLink1 := "C:\\Windows\\System32\\cmd.exe" | |
| filePathLink2 := "C:\\Program Files\\Common Files" | |
| // CellReference Links | |
| cellRefLink1 := "'Test Sheet'!B2" | |
| cellRefLink2 := "FullPathExample" | |
| // External Links | |
| externalLink := "https://products.aspose.com/cells/" | |
| // Email Links | |
| emailLink := "mailto:test@test.com?subject=TestLink" | |
| // Assuming we would use these links somehow in the workbook | |
| // This part can be replaced with actual logic for processing links if required | |
| fmt.Println(filePathLink1) | |
| fmt.Println(filePathLink2) | |
| fmt.Println(cellRefLink1) | |
| fmt.Println(cellRefLink2) | |
| fmt.Println(externalLink) | |
| fmt.Println(emailLink) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| workbook, _ := NewWorkbook_String(srcDir + "LinkTypes.xlsx") | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| if ws == nil { | |
| fmt.Println("Worksheet not found!") | |
| return | |
| } | |
| cells, _ := ws.GetCells() | |
| rng, _ := cells.CreateRange_String("A1:A7") | |
| if rng == nil { | |
| fmt.Println("Range creation failed!") | |
| return | |
| } | |
| hyperlinks, _ := rng.GetHyperlinks() | |
| for i := 0; i < len(hyperlinks); i++ { | |
| link := hyperlinks[i] | |
| if link != (Hyperlink{}) { | |
| text, _ := link.GetTextToDisplay() | |
| linkType, _ := link.GetLinkType() | |
| fmt.Printf("%s: %d\n", text, int(linkType)) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Create an instance of Workbook and load a spreadsheet | |
| book, _ := NewWorkbook_String(srcDir + "sample.xlsx") | |
| // Access the protected Worksheet | |
| wss, _ := book.GetWorksheets() | |
| sheet, _ := wss.Get_Int(0) | |
| // Check if Worksheet is password protected | |
| protection, _ := sheet.GetProtection() | |
| if isProtected, _ := protection.IsProtectedWithPassword(); isProtected { | |
| fmt.Println("Worksheet is password protected") | |
| } else { | |
| fmt.Println("Worksheet is not password protected") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create an instance of Workbook and load an existing spreadsheet | |
| book, _ := NewWorkbook_String("..\\Data\\01_SourceDirectory\\sample.xlsx") | |
| // Loop over all worksheets in the workbook | |
| sheets, _ := book.GetWorksheets() | |
| count, _ := sheets.GetCount() | |
| for i := int32(0); i < count; i++ { | |
| sheet, _ := sheets.Get_Int(i) | |
| // Check if worksheet has populated cells | |
| cells, _ := sheet.GetCells() | |
| maxDataRow, _ := cells.GetMaxDataRow() | |
| if maxDataRow != -1 { | |
| name, _ := sheet.GetName() | |
| fmt.Printf("%s is not empty because one or more cells are populated\n", name) | |
| } else { | |
| // Check if worksheet has shapes | |
| shapes, _ := sheet.GetShapes() | |
| shapeCount, _ := shapes.GetCount() | |
| if shapeCount > 0 { | |
| name, _ := sheet.GetName() | |
| fmt.Printf("%s is not empty because there are one or more shapes\n", name) | |
| } else { | |
| // Check if worksheet has empty initialized cells | |
| displayRange, _ := cells.GetMaxDisplayRange() | |
| rangeIterator, _ := displayRange.GetEnumerator() | |
| hasNext, _ := rangeIterator.MoveNext() | |
| if hasNext { | |
| name, _ := sheet.GetName() | |
| fmt.Printf("%s is not empty because one or more cells are initialized\n", name) | |
| } | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Load the first workbook having automatic paper size false | |
| wb1, _ := NewWorkbook_String(sourceDir + "samplePageSetupIsAutomaticPaperSize-False.xlsx") | |
| // Load the second workbook having automatic paper size true | |
| wb2, _ := NewWorkbook_String(sourceDir + "samplePageSetupIsAutomaticPaperSize-True.xlsx") | |
| // Access the first worksheet of both workbooks | |
| wss1, _ := wb1.GetWorksheets() | |
| ws11, _ := wss1.Get_Int(0) | |
| wss2, _ := wb2.GetWorksheets() | |
| ws12, _ := wss2.Get_Int(0) | |
| // Print the PageSetup.IsAutomaticPaperSize property of both worksheets | |
| pageSetup1, _ := ws11.GetPageSetup() | |
| isAutomaticPaperSize1, _ := pageSetup1.IsAutomaticPaperSize() | |
| fmt.Printf("First Worksheet of First Workbook - IsAutomaticPaperSize: %v\n", isAutomaticPaperSize1) | |
| pageSetup2, _ := ws12.GetPageSetup() | |
| isAutomaticPaperSize2, _ := pageSetup2.IsAutomaticPaperSize() | |
| fmt.Printf("First Worksheet of Second Workbook - IsAutomaticPaperSize: %v\n", isAutomaticPaperSize2) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Load the sample smart art shape - Excel file | |
| inputFilePath := "sampleSmartArtShape.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Access first shape | |
| shapes, _ := ws.GetShapes() | |
| sh, _ := shapes.Get_Int(0) | |
| // Determine if shape is smart art | |
| isSmartArt, _ := sh.IsSmartArt() | |
| fmt.Println("Is Smart Art Shape:", isSmartArt) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Create source directory path | |
| // Removed unused variable | |
| // srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Create a workbook object | |
| workbook, _ := NewWorkbook_String("source.xlsx") | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the chart | |
| charts, _ := worksheet.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Determine which axis exists in the chart | |
| ret, _ := chart.HasAxis(AxisType_Category, true) | |
| fmt.Printf("Has Primary Category Axis: %v\n", ret) | |
| ret, _ = chart.HasAxis(AxisType_Category, false) | |
| fmt.Printf("Has Secondary Category Axis: %v\n", ret) | |
| ret, _ = chart.HasAxis(AxisType_Value, true) | |
| fmt.Printf("Has Primary Value Axis: %v\n", ret) | |
| ret, _ = chart.HasAxis(AxisType_Value, false) | |
| fmt.Printf("Has Secondary Value Axis: %v\n", ret) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Path to the documents directory. | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Open a template file | |
| templateFilePath := srcDir + "sample.xlsx" | |
| workbook, _ := NewWorkbook_String(templateFilePath) | |
| // Disable the compatibility checker | |
| settings, _ := workbook.GetSettings() | |
| settings.SetCheckCompatibility(false) | |
| // Path to save the output file | |
| outputFilePath := srcDir + "Output_BK_CompCheck.out.xlsx" | |
| // Saving the Excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load sample workbook | |
| wb, _ := NewWorkbook_String(srcDir + "sampleDisableCss.xlsx") | |
| // Disable CSS | |
| opts := new(HtmlSaveOptions) | |
| opts.SetDisableCss(true) | |
| // Save the workbook in HTML | |
| wb.Save_String_SaveOptions(outDir + "outputDisable.html", opts.ToSaveOptions()) | |
| fmt.Println("Workbook saved with CSS disabled successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Load sample workbook | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| wb, _ := NewWorkbook_String(sourceDir + "sampleDisableDownlevelRevealedComments.xlsx") | |
| // Disable DisableDownlevelRevealedComments | |
| opts, _ := NewHtmlSaveOptions() | |
| opts.SetDisableDownlevelRevealedComments(true) | |
| // Save the workbook in html | |
| newSaveOptions := opts.ToSaveOptions() | |
| wb.Save_String_SaveOptions(outputDir + "outputDisableDownlevelRevealedComments_true.html", newSaveOptions) | |
| fmt.Println("Workbook saved successfully with DisableDownlevelRevealedComments enabled!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open the required workbook to convert | |
| inputFilePath := srcDir + "Sample1.xlsx" | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Disable exporting frame scripts and document properties | |
| options := new(HtmlSaveOptions) | |
| options.SetExportFrameScriptsAndProperties(false) | |
| // Save workbook as HTML | |
| workbook.Save_String_SaveOptions(outDir + "output.out.html", options.ToSaveOptions()) | |
| fmt.Println("Workbook saved successfully as HTML!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "pivot_table_test.xlsx" | |
| // Path of output excel file | |
| outputFilePath := outDir + "out.xlsx" | |
| // Create workbook | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Access the pivot table in the first sheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| pts, _ := ws.GetPivotTables() | |
| pt, _ := pts.Get_Int(0) | |
| // Disable ribbon for this pivot table | |
| pt.SetEnableWizard(false) | |
| // Save output file | |
| wb.Save_String(outputFilePath) | |
| fmt.Println("Pivot table ribbon disabled successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "sample.xlsx" | |
| // Path of output Excel file | |
| outputFilePath := outDir + "Output_out.xlsx" | |
| // Load the sample Excel file inside the workbook object | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access the first chart inside the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Disable the Text Wrapping of Data Labels in all Series | |
| nSeries, _ := chart.GetNSeries() | |
| series0, _ := nSeries.Get(0) | |
| dataLabels0, _ := series0.GetDataLabels() | |
| dataLabels0.SetIsTextWrapped(false) | |
| series1, _ := nSeries.Get(1) | |
| dataLabels1, _ := series1.GetDataLabels() | |
| dataLabels1.SetIsTextWrapped(false) | |
| series2, _ := nSeries.Get(2) | |
| dataLabels2, _ := series2.GetDataLabels() | |
| dataLabels2.SetIsTextWrapped(false) | |
| // Save the workbook | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Text wrapping disabled successfully in data labels!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create workbook object | |
| workbook, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access cell A1 | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A1") | |
| // Set the HTML string | |
| cell.SetHtmlString("<font style='font-family:Arial;font-size:10pt;color:#666666;vertical-align:top;text-align:left;'>Text 1 </font>" + | |
| "<font style='font-family:Wingdings;font-size:8.0pt;color:#009DD9;mso-font-charset:2;'>l</font>" + | |
| "<font style='font-family:Arial;font-size:10pt;color:#666666;vertical-align:top;text-align:left;'> Text 2 </font>" + | |
| "<font style='font-family:Wingdings;font-size:8.0pt;color:#009DD9;mso-font-charset:2;'>l</font>" + | |
| "<font style='font-family:Arial;font-size:10pt;color:#666666;vertical-align:top;text-align:left;'> Text 3 </font>" + | |
| "<font style='font-family:Wingdings;font-size:8.0pt;color:#009DD9;mso-font-charset:2;'>l</font>" + | |
| "<font style='font-family:Arial;font-size:10pt;color:#666666;vertical-align:top;text-align:left;'> Text 4 </font>") | |
| // Auto fit the Columns | |
| worksheet.AutoFitColumns() | |
| // Save the workbook | |
| outputFilePath := "BulletsInCells_out.xlsx" | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| // Removed unused variable | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := outDir + "SampleSlicerChart.xlsx" | |
| // Path of output pdf file | |
| outputFilePath := outDir + "SampleSlicerChart.pdf" | |
| // Create workbook from the excel file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Save the workbook as a PDF file | |
| workbook.Save_String_SaveFormat(outputFilePath, SaveFormat_Pdf) | |
| fmt.Println("Workbook saved as PDF successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Load the sample Excel file | |
| workbook, _ := NewWorkbook_String("input.xlsx") | |
| // Save the workbook as a PDF file | |
| workbook.Save_String_SaveFormat("output.pdf", SaveFormat_Pdf) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Load sample Excel file | |
| inputFilePath := "input.xlsx" | |
| wb, _ := NewWorkbook_String(inputFilePath) | |
| // Save file to pdf | |
| outputFilePath := "out.pdf" | |
| wb.Save_String_SaveFormat(outputFilePath, SaveFormat_Pdf) | |
| fmt.Println("Workbook saved successfully as PDF!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Assuming workbook and worksheet are already defined | |
| wb, _ := NewWorkbook_String("your_workbook_path.xlsx") | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Define the formula | |
| formula := "=OFFSET(Sheet1!$A$3,0,MATCH($A$10, $B$2:$M$2, 0),3,1)" | |
| // Assuming the cell to which the formula is applied | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("A1") // Update the cell reference as necessary | |
| cell.SetFormula_String(formula) | |
| // Save the workbook | |
| wb.Save_String("output_workbook_path.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Instantiate a Workbook object | |
| workbook, _ := NewWorkbook_String("dynamicArrayFormula.xlsx") | |
| // Get the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Getting the F16 | |
| cells, _ := ws.GetCells() | |
| f16, _ := cells.Get_Int_Int(15, 5) // Adjusted to use row and column indices | |
| // Set dynamic array formula | |
| f16.SetFormula_String("=FILTER(A2:C15,(A2:A15=F4)*(C2:C15=25),\"\")") // Changed to SetFormula_String | |
| // Calculate formula | |
| workbook.CalculateFormula() | |
| workbook.Save_String("out.xlsx") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Create new workbook | |
| workbook, _ := NewWorkbook_FileFormatType(FileFormatType_Xlsx) | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Add data for chart | |
| // Category Axis Values | |
| cells, _ := worksheet.GetCells() | |
| cell, _ := cells.Get_String("A2") | |
| cell.PutValue_String("C1") | |
| cell, _ = cells.Get_String("A3") | |
| cell.PutValue_String("C2") | |
| cell, _ = cells.Get_String("A4") | |
| cell.PutValue_String("C3") | |
| // First vertical series | |
| cell, _ = cells.Get_String("B1") | |
| cell.PutValue_String("T1") | |
| cell, _ = cells.Get_String("B2") | |
| cell.PutValue_Int(6) | |
| cell, _ = cells.Get_String("B3") | |
| cell.PutValue_Int(3) | |
| cell, _ = cells.Get_String("B4") | |
| cell.PutValue_Int(2) | |
| // Second vertical series | |
| cell, _ = cells.Get_String("C1") | |
| cell.PutValue_String("T2") | |
| cell, _ = cells.Get_String("C2") | |
| cell.PutValue_Int(7) | |
| cell, _ = cells.Get_String("C3") | |
| cell.PutValue_Int(2) | |
| cell, _ = cells.Get_String("C4") | |
| cell.PutValue_Int(5) | |
| // Third vertical series | |
| cell, _ = cells.Get_String("D1") | |
| cell.PutValue_String("T3") | |
| cell, _ = cells.Get_String("D2") | |
| cell.PutValue_Int(8) | |
| cell, _ = cells.Get_String("D3") | |
| cell.PutValue_Int(4) | |
| cell, _ = cells.Get_String("D4") | |
| cell.PutValue_Int(2) | |
| // Create Column chart with easy way | |
| charts, _ := worksheet.GetCharts() | |
| idx, _ := charts.Add_ChartType_Int_Int_Int_Int(ChartType_Column, 6, 5, 20, 13) | |
| ch, _ := charts.Get_Int(idx) | |
| ch.SetChartDataRange("A1:D4", true) | |
| // Save the workbook | |
| outputPath := "..\\Data\\02_OutputDirectory\\output_out.xlsx" | |
| workbook.Save_String_SaveFormat(outputPath, SaveFormat_Xlsx) | |
| fmt.Println("Workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook from input file | |
| workbook, _ := NewWorkbook_String(srcDir + "Sample.xlsx") | |
| // Access the first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Iterate through all hyperlinks in the worksheet | |
| hyperlinks, _ := worksheet.GetHyperlinks() | |
| count, _ := hyperlinks.GetCount() | |
| for i := int32(0); i < count; i++ { | |
| hl, _ := hyperlinks.Get(i) | |
| hl.SetAddress("http://www.aspose.com") | |
| } | |
| // Save the modified workbook to the output file | |
| workbook.Save_String(outDir + "output_out.xlsx") | |
| fmt.Println("Hyperlinks updated successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Open the template file | |
| workbook, _ := NewWorkbook_String("embedded-attachments-example.xlsx") | |
| // Set to embed Ole Object attachment. | |
| pdfSaveOptions := new(PdfSaveOptions) | |
| pdfSaveOptions.SetEmbedAttachments(true) | |
| // Save the pdf file with PdfSaveOptions | |
| newPdfSaveOptions := pdfSaveOptions.ToSaveOptions() | |
| workbook.Save_String_SaveOptions("output.pdf", newPdfSaveOptions) | |
| fmt.Println("PDF saved successfully with embedded attachments!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Load sample workbook | |
| wb, _ := NewWorkbook_String(srcDir + "sampleEnableCssCustomProperties.xlsx") | |
| // Create HtmlSaveOptions object | |
| opts, _ := NewHtmlSaveOptions() | |
| // Set ExportImagesAsBase64 to true | |
| opts.SetExportImagesAsBase64(true) | |
| // Enable EnableCssCustomProperties | |
| opts.SetEnableCssCustomProperties(true) | |
| // Save the workbook in HTML format | |
| wb.Save_String_SaveOptions(outDir + "outputEnableCssCustomProperties.html", opts.ToSaveOptions()) | |
| println("Workbook saved successfully with CSS custom properties enabled!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| workbook, _ := NewWorkbook_String("sampleWorksheetViews.xlsx") | |
| worksheets, _ := workbook.GetWorksheets() | |
| worksheet, _ := worksheets.Get_Int(0) | |
| worksheet.SetIsPageBreakPreview(true) | |
| workbook.Save_String("Data/Output/outputWorksheetViews.xlsx") | |
| fmt.Println("Worksheet views are enabled successfully.") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Path to the source directory | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open an encrypted ODS file | |
| loadOptions,_ := NewLoadOptions() | |
| // Set original password | |
| loadOptions.SetPassword("1234") | |
| // Load the encrypted ODS file with the appropriate load options | |
| workbook,_ := NewWorkbook_String(sourceDir + "sampleEncryptedODSFile.ods") | |
| // Set the password to an empty string | |
| settings,_ := workbook.GetSettings() | |
| settings.SetPassword("") | |
| // Save the decrypted ODS file | |
| workbook.Save_String(outputDir + "outputDecryptedODSFile.ods") | |
| fmt.Println("Decrypted ODS file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C++ | |
| // Source directory path | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open an ODS file | |
| workbook, _ := NewWorkbook_String(sourceDir + "sampleODSFile.ods") | |
| // Password protect the file | |
| settings, _ := workbook.GetSettings() | |
| settings.SetPassword("1234") | |
| // Save the ODS file | |
| workbook.Save_String(outputDir + "outputEncryptedODSFile.ods") | |
| fmt.Println("ODS file password protected and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "Book1.xls" | |
| // Path of output excel file | |
| outputFilePath := outDir + "SpecifyPasswordToModifyOption.out.xls" | |
| // Create workbook | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Set the password for modification | |
| settings, _ := workbook.GetSettings() | |
| writeProtection, _ := settings.GetWriteProtection() | |
| writeProtection.SetPassword("1234") | |
| // Save the excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Password for modification set successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| inputPath := srcDir + "EncryptedBook1.xlsx" | |
| // Read file data | |
| fileData, err := ioutil.ReadFile(inputPath) | |
| if err != nil { | |
| fmt.Println("Error reading file:", err) | |
| return | |
| } | |
| data := fileData // Removed incorrect function call | |
| isPasswordValid, _ := FileFormatUtil_VerifyPassword(data, "123456") | |
| fmt.Printf("Password is Valid: %t\n", isPasswordValid) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C++ | |
| // Source directory path | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open an ODS file | |
| workbook, _ := NewWorkbook_String(sourceDir + "sampleODSFile.ods") | |
| // Password protect the file | |
| settings, _ := workbook.GetSettings() | |
| settings.SetPassword("1234") | |
| // Save the ODS file | |
| workbook.Save_String(outputDir + "outputEncryptedODSFile.ods") | |
| fmt.Println("ODS file password protected and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Path to the source directory | |
| sourceDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory | |
| outputDir := "..\\Data\\02_OutputDirectory\\" | |
| // Open an encrypted ODS file | |
| loadOptions,_ := NewLoadOptions() | |
| // Set original password | |
| loadOptions.SetPassword("1234") | |
| // Load the encrypted ODS file with the appropriate load options | |
| workbook,_ := NewWorkbook_String(sourceDir + "sampleEncryptedODSFile.ods") | |
| // Set the password to an empty string | |
| settings, _ := workbook.GetSettings() | |
| settings.SetPassword("") | |
| // Save the decrypted ODS file | |
| workbook.Save_String(outputDir + "outputDecryptedODSFile.ods") | |
| fmt.Println("Decrypted ODS file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| inputFilePath := srcDir + "Book1.xls" | |
| // Path of output excel file | |
| outputFilePath := outDir + "encryptedBook1.out.xls" | |
| // Instantiate a Workbook object and open the excel file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Specify XOR encryption type | |
| workbook.SetEncryptionOptions(EncryptionType_XOR, 40) | |
| // Specify Strong Encryption type (RC4, Microsoft Strong Cryptographic Provider) | |
| workbook.SetEncryptionOptions(EncryptionType_StrongCryptographicProvider, 128) | |
| // Password protect the file | |
| settings, _ := workbook.GetSettings() | |
| settings.SetPassword("1234") | |
| // Save the encrypted excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("File encrypted and saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create workbook from existing Excel file | |
| workbook, _ := NewWorkbook_String("Sample.xlsx") | |
| // Access VBA project modules | |
| vbaProject, _ := workbook.GetVbaProject() | |
| modules, _ := vbaProject.GetModules() | |
| // Set VBA code for 'ThisWorkbook' module | |
| thisWorkbookModule, _ := modules.Get_String("ThisWorkbook") | |
| thisWorkbookModule.SetCodes("Private Sub Workbook_BeforePrint(Cancel As Boolean)\r\n Cancel = True\r\n MsgBox \"Refusing to print in paperless office\"\r\nEnd Sub\r\n") | |
| // Save the workbook as macro-enabled Excel file | |
| workbook.Save_String("out.xlsm") | |
| fmt.Println("VBA code added and workbook saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Create workbook | |
| workbook, _ := NewWorkbook() | |
| // Get cells collection in the first (default) worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| cells, _ := ws.GetCells() | |
| // Get the D3 cell | |
| cell, _ := cells.Get_String("D3") | |
| // Get the style of the cell | |
| style, _ := cell.GetStyle() | |
| // Set foreground color for the cell from the default theme Accent2 color | |
| themeColor1, _ := NewThemeColor(0, 0.5) | |
| style.SetForegroundThemeColor(themeColor1) | |
| // Set the pattern type | |
| style.SetPattern(BackgroundType_Solid) | |
| // Get the font for the style | |
| font, _ := style.GetFont() | |
| // Set the theme color | |
| themeColor2, _ := NewThemeColor(1, 0.1) | |
| font.SetThemeColor(themeColor2) | |
| // Apply style | |
| cell.SetStyle_Style(style) // Use the correct method to set style | |
| // Put a value | |
| cell.PutValue_String("Testing1") | |
| // Save the excel file | |
| workbook.Save_String(outDir + "output.out.xlsx") | |
| fmt.Println("Excel file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Define Color array (of 12 colors) for Theme | |
| carr := make([]Color, 12) | |
| color1, _ := Color_AntiqueWhite() | |
| carr[0] = *color1 // Background1 | |
| color2, _ := Color_Brown() | |
| carr[1] = *color2 // Text1 | |
| color3, _ := Color_AliceBlue() | |
| carr[2] = *color3 // Background2 | |
| color4, _ := Color_Yellow() | |
| carr[3] = *color4 // Text2 | |
| color5, _ := Color_YellowGreen() | |
| carr[4] = *color5 // Accent1 | |
| color6, _ := Color_Red() | |
| carr[5] = *color6 // Accent2 | |
| color7, _ := Color_Pink() | |
| carr[6] = *color7 // Accent3 | |
| color8, _ := Color_Purple() | |
| carr[7] = *color8 // Accent4 | |
| color9, _ := Color_PaleGreen() | |
| carr[8] = *color9 // Accent5 | |
| color10, _ := Color_Orange() | |
| carr[9] = *color10 // Accent6 | |
| color11, _ := Color_Green() | |
| carr[10] = *color11 // Hyperlink | |
| color12, _ := Color_Gray() | |
| carr[11] = *color12 // Followed Hyperlink | |
| // Path of input excel file | |
| inputFilePath := srcDir + "book1.xlsx" | |
| // Instantiate a Workbook and open the template file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Set the custom theme with specified colors | |
| workbook.CustomTheme("CustomeTheme1", carr) | |
| // Path of output excel file | |
| outputFilePath := outDir + "output.out.xlsx" | |
| // Save as the excel file | |
| workbook.Save_String(outputFilePath) | |
| fmt.Println("Custom theme applied and file saved successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Path of input Excel file | |
| inputFilePath := srcDir + "sample.xlsx" | |
| // Instantiate the Workbook and load an Excel file | |
| workbook, _ := NewWorkbook_String(inputFilePath) | |
| // Create HtmlSaveOptions object | |
| options := new(HtmlSaveOptions) | |
| // Set the Presentation preference option | |
| options.SetPresentationPreference(true) | |
| // Save the Excel file to HTML with specified option | |
| workbook.Save_String_SaveOptions(srcDir + "outPresentationlayout1.out.html", options.ToSaveOptions()) | |
| println("Excel file saved as HTML successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Create workbook | |
| wb, _ := NewWorkbook() | |
| // Access first worksheet | |
| wss, _ := wb.GetWorksheets() | |
| ws, _ := wss.Get_Int(0) | |
| // Put some value in cell C7 | |
| cells, _ := ws.GetCells() | |
| cell, _ := cells.Get_String("C7") | |
| cell.PutValue_String("This is sample text.") | |
| // Specify html save options, we want to exclude unused styles | |
| opts, _ := NewHtmlSaveOptions() | |
| // Comment this line to include unused styles | |
| opts.SetExcludeUnusedStyles(true) | |
| // Save the workbook in html format | |
| wb.Save_String_SaveOptions("outputExcludeUnusedStylesInExcelToHTML.html", opts.ToSaveOptions()) | |
| println("Workbook saved successfully with unused styles excluded!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Load source excel file inside the workbook object | |
| wb, _ := NewWorkbook_String(srcDir + "sample.xlsx") | |
| // Save workbook in html format | |
| version, _ := CellsHelper_GetVersion() | |
| outputPath := srcDir + "ExpandTextFromRightToLeft_out_" + version + ".html" | |
| wb.Save_String_SaveFormat(outputPath, SaveFormat_Html) | |
| println("Workbook saved successfully in HTML format!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // Source directory path | |
| // Removed unused variable | |
| // srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Output directory path | |
| outDir := "..\\Data\\02_OutputDirectory\\" | |
| // Path of input excel file | |
| filePath := outDir + "sample.xlsx" | |
| // Load your sample excel file in a workbook object | |
| wb, _ := NewWorkbook_String(filePath) | |
| // Save it in HTML format | |
| wb.Save_String_SaveFormat(outDir + "ConvertingToHTMLFiles_out.html", SaveFormat_Html) | |
| fmt.Println("File converted to HTML successfully!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| . "github.com/aspose-cells/aspose-cells-go-cpp/v25" | |
| ) | |
| func main() { | |
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
| // Source directory path | |
| srcDir := "..\\Data\\01_SourceDirectory\\" | |
| // Create workbook object from source file | |
| sampleChartBook := srcDir + "SampleChartBook.xlsx" | |
| workbook, _ := NewWorkbook_String(sampleChartBook) | |
| // Access first worksheet | |
| wss, _ := workbook.GetWorksheets() | |
| worksheet, _ := wss.Get_Int(0) | |
| // Access first chart inside the worksheet | |
| charts, _ := worksheet.GetCharts() | |
| chart, _ := charts.Get_Int(0) | |
| // Set image options | |
| opts, _ := NewImageOrPrintOptions() | |
| opts.SetImageType(ImageType_Svg) | |
| // Save the chart to svg format | |
| outputSvg := srcDir + "Image_out.svg" | |
| chart.ToImage_String_ImageOrPrintOptions(outputSvg, opts) | |
| fmt.Println("Chart saved successfully in SVG format!") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment