Last active
November 10, 2020 20:01
-
-
Save aspose-com-gists/0edd1c91ebaa6cd099be1200b1ec7480 to your computer and use it in GitHub Desktop.
This Gist contains code snippets of Aspose.Cells for C++
This file contains bidirectional Unicode text that may be interpreted or compiled 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 snippets of Aspose.Cells for C++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of output excel file | |
StringPtr outputChartTypeBubble = outDir->StringAppend(new String("outputChartTypeBubble.xlsx")); | |
// Create a new workbook | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(); | |
// Get first worksheet which is created by default | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Fill in data for chart's series | |
// Y Values | |
worksheet->GetICells()->GetObjectByIndex(0, 0)->PutValue((StringPtr)new String("Y Values")); | |
worksheet->GetICells()->GetObjectByIndex(0, 1)->PutValue(2); | |
worksheet->GetICells()->GetObjectByIndex(0, 2)->PutValue(4); | |
worksheet->GetICells()->GetObjectByIndex(0, 3)->PutValue(6); | |
// Bubble Size | |
worksheet->GetICells()->GetObjectByIndex(1, 0)->PutValue((StringPtr)new String("Bubble Size")); | |
worksheet->GetICells()->GetObjectByIndex(1, 1)->PutValue(2); | |
worksheet->GetICells()->GetObjectByIndex(1, 2)->PutValue(3); | |
worksheet->GetICells()->GetObjectByIndex(1, 3)->PutValue(1); | |
// X Values | |
worksheet->GetICells()->GetObjectByIndex(2, 0)->PutValue((StringPtr)new String("X Values")); | |
worksheet->GetICells()->GetObjectByIndex(2, 1)->PutValue(1); | |
worksheet->GetICells()->GetObjectByIndex(2, 2)->PutValue(2); | |
worksheet->GetICells()->GetObjectByIndex(2, 3)->PutValue(3); | |
// Set first column width | |
worksheet->GetICells()->SetColumnWidth(0, 12); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet->GetICharts()->Add(Aspose::Cells::Charts::ChartType::ChartType_Bubble, 5, 0, 20, 8); | |
// Accessing the instance of the newly added chart | |
intrusive_ptr<Aspose::Cells::Charts::IChart> chart = worksheet->GetICharts()->GetObjectByIndex(chartIndex); | |
// Adding SeriesCollection (chart data source) to the chart ranging from B1 to D1 | |
chart->GetNISeries()->Add(new String("B1:D1"), true); | |
// Set bubble sizes | |
chart->GetNISeries()->GetObjectByIndex(0)->SetBubbleSizes(new String("B2:D2")); | |
// Set X axis values | |
chart->GetNISeries()->GetObjectByIndex(0)->SetXValues(new String("B3:D3")); | |
// Set Y axis values | |
chart->GetNISeries()->GetObjectByIndex(0)->SetValues(new String("B1:D1")); | |
// Saving the Excel file | |
workbook->Save(outputChartTypeBubble); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of output excel file | |
StringPtr outputChartTypeCustom = outDir->StringAppend(new String("outputChartTypeCustom.xlsx")); | |
// Create a new workbook | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(); | |
// Get first worksheet which is created by default | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Adding sample values to cells | |
worksheet->GetICells()->GetObjectByIndex(new String("A1"))->PutValue(50); | |
worksheet->GetICells()->GetObjectByIndex(new String("A2"))->PutValue(100); | |
worksheet->GetICells()->GetObjectByIndex(new String("A3"))->PutValue(150); | |
worksheet->GetICells()->GetObjectByIndex(new String("A4"))->PutValue(110); | |
worksheet->GetICells()->GetObjectByIndex(new String("B1"))->PutValue(260); | |
worksheet->GetICells()->GetObjectByIndex(new String("B2"))->PutValue(12); | |
worksheet->GetICells()->GetObjectByIndex(new String("B3"))->PutValue(50); | |
worksheet->GetICells()->GetObjectByIndex(new String("B4"))->PutValue(100); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet->GetICharts()->Add(Aspose::Cells::Charts::ChartType::ChartType_Column, 5, 0, 20, 8); | |
// Accessing the instance of the newly added chart | |
intrusive_ptr<Aspose::Cells::Charts::IChart> chart = worksheet->GetICharts()->GetObjectByIndex(chartIndex); | |
// Adding SeriesCollection (chart data source) to the chart ranging from A1 to B4 | |
chart->GetNISeries()->Add(new String("A1:B4"), true); | |
// Setting the chart type of 2nd NSeries to display as line chart | |
chart->GetNISeries()->GetObjectByIndex(1)->SetType(Aspose::Cells::Charts::ChartType::ChartType_Line); | |
// Saving the Excel file | |
workbook->Save(outputChartTypeCustom); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of output excel file | |
StringPtr outputChartTypeLine = outDir->StringAppend(new String("outputChartTypeLine.xlsx")); | |
// Create a new workbook | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(); | |
// Get first worksheet which is created by default | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Adding sample values to cells | |
worksheet->GetICells()->GetObjectByIndex(new String("A1"))->PutValue(50); | |
worksheet->GetICells()->GetObjectByIndex(new String("A2"))->PutValue(100); | |
worksheet->GetICells()->GetObjectByIndex(new String("A3"))->PutValue(150); | |
worksheet->GetICells()->GetObjectByIndex(new String("B1"))->PutValue(4); | |
worksheet->GetICells()->GetObjectByIndex(new String("B2"))->PutValue(20); | |
worksheet->GetICells()->GetObjectByIndex(new String("B3"))->PutValue(50); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet->GetICharts()->Add(Aspose::Cells::Charts::ChartType::ChartType_Line, 5, 0, 20, 8); | |
// Accessing the instance of the newly added chart | |
intrusive_ptr<Aspose::Cells::Charts::IChart> chart = worksheet->GetICharts()->GetObjectByIndex(chartIndex); | |
// Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
chart->GetNISeries()->Add(new String("A1:B3"), true); | |
// Saving the Excel file | |
workbook->Save(outputChartTypeLine); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of output excel file | |
StringPtr outputChartTypePyramid = outDir->StringAppend(new String("outputChartTypePyramid.xlsx")); | |
// Create a new workbook | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(); | |
// Get first worksheet which is created by default | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Adding sample values to cells | |
worksheet->GetICells()->GetObjectByIndex(new String("A1"))->PutValue(50); | |
worksheet->GetICells()->GetObjectByIndex(new String("A2"))->PutValue(100); | |
worksheet->GetICells()->GetObjectByIndex(new String("A3"))->PutValue(150); | |
worksheet->GetICells()->GetObjectByIndex(new String("B1"))->PutValue(4); | |
worksheet->GetICells()->GetObjectByIndex(new String("B2"))->PutValue(20); | |
worksheet->GetICells()->GetObjectByIndex(new String("B3"))->PutValue(50); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet->GetICharts()->Add(Aspose::Cells::Charts::ChartType::ChartType_Pyramid, 5, 0, 20, 8); | |
// Accessing the instance of the newly added chart | |
intrusive_ptr<Aspose::Cells::Charts::IChart> chart = worksheet->GetICharts()->GetObjectByIndex(chartIndex); | |
// Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
chart->GetNISeries()->Add(new String("A1:B3"), true); | |
// Saving the Excel file | |
workbook->Save(outputChartTypePyramid); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleReadAndManipulateExcel2016Charts = srcDir->StringAppend(new String("sampleReadAndManipulateExcel2016Charts.xlsx")); | |
//Path of output excel file | |
StringPtr outputReadAndManipulateExcel2016Charts = outDir->StringAppend(new String("outputReadAndManipulateExcel2016Charts.xlsx")); | |
// Load sample Excel file containing Excel 2016 charts | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleReadAndManipulateExcel2016Charts); | |
// Access the first worksheet which contains the charts | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Access all charts one by one and read their types | |
for (int i = 0; i < worksheet->GetICharts()->GetCount(); i++) | |
{ | |
// Access the chart | |
intrusive_ptr<IChart> ch = worksheet->GetICharts()->GetObjectByIndex(i); | |
//Get the chart type | |
ChartType chartType = ch->GetType(); | |
//Convert chart type enum to string | |
StringPtr strChartType = NULL; | |
switch (chartType) | |
{ | |
case Aspose::Cells::Charts::ChartType_BoxWhisker: | |
strChartType = new String("BoxWhisker"); | |
break; | |
case Aspose::Cells::Charts::ChartType_Histogram: | |
strChartType = new String("Histogram"); | |
break; | |
case Aspose::Cells::Charts::ChartType_Sunburst: | |
strChartType = new String("Sunburst"); | |
break; | |
case Aspose::Cells::Charts::ChartType_Treemap: | |
strChartType = new String("Treemap"); | |
break; | |
case Aspose::Cells::Charts::ChartType_Waterfall: | |
strChartType = new String("Waterfall"); | |
break; | |
default: | |
break; | |
} | |
// Print chart type | |
Aspose::Cells::Systems::Console::WriteLine(strChartType); | |
// Change the title of the charts as per their types | |
StringPtr strTitle = (StringPtr)(new String("Chart Type is "))->Append(strChartType); | |
ch->GetITitle()->SetText(strTitle); | |
} | |
// Save the workbook | |
workbook->Save(outputReadAndManipulateExcel2016Charts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Source directory path. | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
// Output directory path. | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleExtractingOLEObjectsFromWorksheet = srcDir->StringAppend(new String("sampleExtractingOLEObjectsFromWorksheet.xlsx")); | |
// Load sample Excel file containing OLE objects. | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleExtractingOLEObjectsFromWorksheet); | |
// Get the first worksheet. | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Create File object. | |
intrusive_ptr<Aspose::Cells::Systems::IO::File> ioFile = new Aspose::Cells::Systems::IO::File(); | |
// Access the count of Ole objects. | |
Aspose::Cells::Systems::Int32 oleCount = worksheet->GetIOleObjects()->GetCount(); | |
// Iterate all the Ole objects and save to disk with correct file format extension. | |
for (int i = 0; i < oleCount; i++) | |
{ | |
// Access Ole object. | |
intrusive_ptr<Aspose::Cells::Drawing::IOleObject> oleObj = worksheet->GetIOleObjects()->GetObjectByIndex(i); | |
// Access the Ole ProgID. | |
intrusive_ptr<Aspose::Cells::Systems::String> strProgId = oleObj->GetProgID(); | |
// Find the correct file extension. | |
intrusive_ptr<Aspose::Cells::Systems::String> fileExt = NULL; | |
if (strProgId->Equals(new String("Document")) == true) | |
{ | |
fileExt = new Aspose::Cells::Systems::String(".docx"); | |
} | |
else if (strProgId->Equals(new String("Presentation")) == true) | |
{ | |
fileExt = new Aspose::Cells::Systems::String(".pptx"); | |
} | |
else if (strProgId->Equals(new String("Acrobat Document")) == true) | |
{ | |
fileExt = new Aspose::Cells::Systems::String(".pdf"); | |
} | |
// Find the correct file name with file extension. | |
intrusive_ptr<Aspose::Cells::Systems::String> fileName = outDir->StringAppend(new String("outputExtractOleObject"))->StringAppend(fileExt); | |
// Write the Ole object data with correct file name. | |
intrusive_ptr<Aspose::Cells::Systems::IO::FileStream> fout = new Aspose::Cells::Systems::IO::FileStream(fileName, FileMode::FileMode_OpenOrCreate, FileAccess::FileAccess_Write); | |
fout->Write(oleObj->GetObjectData(), 0, oleObj->GetObjectData()->GetLength()); | |
fout->Close(); | |
}//for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Source directory path. | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
// Output directory path. | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of output Excel file. | |
StringPtr outputInsertingOLEObjectsIntoWorksheet = outDir->StringAppend(new String("outputInsertingOLEObjectsIntoWorksheet.xlsx")); | |
// Instantiate a new workbook. | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(); | |
// Get the first worksheet. | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Create File object. | |
intrusive_ptr<Aspose::Cells::Systems::IO::File> ioFile = new Aspose::Cells::Systems::IO::File(); | |
// Read Image for Ole Object into array of bytes. | |
StringPtr imagePath = srcDir->StringAppend(new String("AsposeLogo.png")); | |
intrusive_ptr<Array1D<Byte>> imageData = ioFile->ReadAllBytes(imagePath); | |
// Read Ole Object into array of bytes. | |
StringPtr oleObjectPath = srcDir->StringAppend(new String("inputInsertOleObject.xlsx")); | |
intrusive_ptr<Array1D<Byte>> oleObjectData = ioFile->ReadAllBytes(oleObjectPath); | |
// Add an Ole object into the worksheet with the image. | |
Aspose::Cells::Systems::Int32 idx = worksheet->GetIOleObjects()->Add(2, 2, 200, 220, imageData); | |
// Set the Ole object data. | |
intrusive_ptr<Aspose::Cells::Drawing::IOleObject> oleObj = worksheet->GetIOleObjects()->GetObjectByIndex(idx); | |
oleObj->SetObjectData(oleObjectData); | |
// Save the workbook. | |
workbook->Save(outputInsertingOLEObjectsIntoWorksheet); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_Worksheets->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing a worksheet using its index and Get cell by name from worksheet cells collection | |
intrusive_ptr<ICell> cell = workbook->GetIWorksheets()->GetObjectByIndex(0)->GetICells()->GetObjectByIndex(new String("A1")); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Adding a string value to the cell | |
worksheet->GetICells()->GetObjectByIndex(new String("A1"))->PutValue("Hello World"); | |
// Adding a double value to the cell | |
worksheet->GetICells()->GetObjectByIndex(new String("A2"))->PutValue(20.5); | |
// Adding an integer value to the cell | |
worksheet->GetICells()->GetObjectByIndex(new String("A3"))->PutValue(15); | |
// Adding a boolean value to the cell | |
worksheet->GetICells()->GetObjectByIndex(new String("A4"))->PutValue(true); | |
// Setting the display format of the date | |
intrusive_ptr<IStyle> style = worksheet->GetICells()->GetObjectByIndex(new String("A5"))->GetIStyle(); | |
style->SetNumber(15); | |
worksheet->GetICells()->GetObjectByIndex(new String("A5"))->SetStyle(style); | |
workbook->Save(dataDir_Data->StringAppend(new String("AddingDataToCells_out.xlsx"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(); | |
// Adding a new worksheet to the Workbook object | |
int i = workbook->GetIWorksheets()->Add(); | |
// Obtaining the reference of the newly added worksheet by passing its sheet index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(i); | |
// Setting the name of the newly added worksheet | |
worksheet->SetName(new String("My Worksheet")); | |
// Save the Excel file. | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("AddingWorksheetsToNewExcelFile_out.xls"))); | |
printf("\nWorksheet moved successfully with in a workbook!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiating a Workbook object | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(); | |
// Add a page break at cell Y30 | |
workbook->GetIWorksheets()->GetObjectByIndex(0)->AddPageBreaks(new String("Y30")); | |
// Save the Excel file. | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("AddPageBreaks_out.xls"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(sourcePath->StringAppend(new String("aa_filtre.xls"))); | |
intrusive_ptr<IWorksheet> sheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
sheet->GetIAutoFilter()->SetRange(0, 0, 1); | |
sheet->GetIAutoFilter()->Filter(1, new String("Nom2")); | |
sheet->GetIAutoFilter()->Refresh(); | |
EXPECT_TRUE(workbook->GetIWorksheets()->GetObjectByIndex(0)->GetICells()->GetRowHeight(3) == 0); | |
EXPECT_TRUE(workbook->GetIWorksheets()->GetObjectByIndex(0)->GetICells()->GetRowHeight(4) == 0); | |
workbook->Save(sourcePath->StringAppend(new String("aa_filtre_out.xls"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Open an existing Workbook from sourceFile folder | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sourcePath->StringAppend(new String("book.xlsx"))); | |
// Get the first worsheet | |
intrusive_ptr<IWorksheetCollection> wsc = wb->GetIWorksheets(); | |
intrusive_ptr<IWorksheet> ws = wsc->GetObjectByIndex(0); | |
// Get cell(0,0) | |
intrusive_ptr<ICells> cells = ws->GetICells(); | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(0, 0); | |
// Modify the value of the first cell from 100 to 200 * | |
cell->PutValue(200); | |
// Check value | |
EXPECT_TRUE(cell->GetIntValue() == 200); | |
// Save this workbook to resultFile folder | |
wb->Save(sourcePath->StringAppend(new String("ChangeValue_out.xlsx"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Tables->StringAppend(new String("sample.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Get the List objects collection in the first worksheet. | |
intrusive_ptr<IListObjectCollection> listObjects = worksheet->GetIListObjects(); | |
// Convert the first table/list object (from the first worksheet) to normal range | |
listObjects->GetObjectByIndex(0)->ConvertToRange(); | |
// Saving the Excel file | |
workbook->Save(dataDir_Tables->StringAppend(new String("ConvertTableToRange_out.xls"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiating a Workbook object and opening the Excel file through the path | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Copy the first column from the first worksheet of the first workbook into the first worksheet of the second workbook. | |
worksheet->GetICells()->CopyColumn(worksheet->GetICells(), 0, 2); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("CopyColumns_out.xls"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiating a Workbook object and opening the Excel file through the path | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Copy the second row with data, formattings, images and drawing objects to the 16th row in the worksheet. | |
worksheet->GetICells()->CopyRow(worksheet->GetICells(), 1, 15); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("CopyRows_out.xls"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Tables->StringAppend(new String("book1.xls"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Get the List objects collection in the first worksheet. | |
intrusive_ptr<IListObjectCollection> listObjects = worksheet->GetIListObjects(); | |
// Add a List based on the data source range with headers on. | |
listObjects->Add(1, 1, 7, 5, true); | |
// Show the total row for the List. | |
listObjects->GetObjectByIndex(0)->SetShowTotals(true); | |
// Saving the Excel file | |
workbook->Save(dataDir_Tables->StringAppend(new String("CreatingListObjects_out.xls"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Deleting a column from the worksheet at 2nd position | |
worksheet->GetICells()->DeleteColumn(4); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("DeleteColumn_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_OpenOrCreate); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Deleting 10 rows from the worksheet starting from 3rd row | |
worksheet->GetICells()->DeleteRows(2, 10); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("DeleteMultipleRows_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_Worksheets->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Displaying the worksheet in page break preview | |
worksheet->SetIsPageBreakPreview(true); | |
// Saving the modified Excel file | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("EnableNormalView_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(); | |
// Obtaining the reference of the default(first) worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Obtaining Worksheet's cells collection | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
// Setting the value to the cells | |
cells->GetObjectByIndex(new String("A1"))->PutValue("Employee"); | |
cells->GetObjectByIndex(new String("B1"))->PutValue("Quarter"); | |
cells->GetObjectByIndex(new String("C1"))->PutValue("Product"); | |
cells->GetObjectByIndex(new String("D1"))->PutValue("Continent"); | |
cells->GetObjectByIndex(new String("E1"))->PutValue("Country"); | |
cells->GetObjectByIndex(new String("F1"))->PutValue("Sale"); | |
cells->GetObjectByIndex(new String("A2"))->PutValue("David"); | |
cells->GetObjectByIndex(new String("A3"))->PutValue("David"); | |
cells->GetObjectByIndex(new String("A4"))->PutValue("David"); | |
cells->GetObjectByIndex(new String("A5"))->PutValue("David"); | |
cells->GetObjectByIndex(new String("A6"))->PutValue("James"); | |
cells->GetObjectByIndex(new String("A7"))->PutValue("James"); | |
cells->GetObjectByIndex(new String("A8"))->PutValue("James"); | |
cells->GetObjectByIndex(new String("A9"))->PutValue("James"); | |
cells->GetObjectByIndex(new String("A10"))->PutValue("James"); | |
cells->GetObjectByIndex(new String("A11"))->PutValue("Miya"); | |
cells->GetObjectByIndex(new String("A12"))->PutValue("Miya"); | |
cells->GetObjectByIndex(new String("A13"))->PutValue("Miya"); | |
cells->GetObjectByIndex(new String("A14"))->PutValue("Miya"); | |
cells->GetObjectByIndex(new String("A15"))->PutValue("Miya"); | |
cells->GetObjectByIndex(new String("B2"))->PutValue(1); | |
cells->GetObjectByIndex(new String("B3"))->PutValue(2); | |
cells->GetObjectByIndex(new String("B4"))->PutValue(3); | |
cells->GetObjectByIndex(new String("B5"))->PutValue(4); | |
cells->GetObjectByIndex(new String("B6"))->PutValue(1); | |
cells->GetObjectByIndex(new String("B7"))->PutValue(2); | |
cells->GetObjectByIndex(new String("B8"))->PutValue(3); | |
cells->GetObjectByIndex(new String("B9"))->PutValue(4); | |
cells->GetObjectByIndex(new String("B10"))->PutValue(4); | |
cells->GetObjectByIndex(new String("B11"))->PutValue(1); | |
cells->GetObjectByIndex(new String("B12"))->PutValue(1); | |
cells->GetObjectByIndex(new String("B13"))->PutValue(2); | |
cells->GetObjectByIndex(new String("B14"))->PutValue(2); | |
cells->GetObjectByIndex(new String("B15"))->PutValue(2); | |
cells->GetObjectByIndex(new String("C2"))->PutValue("Maxilaku"); | |
cells->GetObjectByIndex(new String("C3"))->PutValue("Maxilaku"); | |
cells->GetObjectByIndex(new String("C4"))->PutValue("Chai"); | |
cells->GetObjectByIndex(new String("C5"))->PutValue("Maxilaku"); | |
cells->GetObjectByIndex(new String("C6"))->PutValue("Chang"); | |
cells->GetObjectByIndex(new String("C7"))->PutValue("Chang"); | |
cells->GetObjectByIndex(new String("C8"))->PutValue("Chang"); | |
cells->GetObjectByIndex(new String("C9"))->PutValue("Chang"); | |
cells->GetObjectByIndex(new String("C10"))->PutValue("Chang"); | |
cells->GetObjectByIndex(new String("C11"))->PutValue("Geitost"); | |
cells->GetObjectByIndex(new String("C12"))->PutValue("Chai"); | |
cells->GetObjectByIndex(new String("C13"))->PutValue("Geitost"); | |
cells->GetObjectByIndex(new String("C14"))->PutValue("Geitost"); | |
cells->GetObjectByIndex(new String("C15"))->PutValue("Geitost"); | |
cells->GetObjectByIndex(new String("D2"))->PutValue("Asia"); | |
cells->GetObjectByIndex(new String("D3"))->PutValue("Asia"); | |
cells->GetObjectByIndex(new String("D4"))->PutValue("Asia"); | |
cells->GetObjectByIndex(new String("D5"))->PutValue("Asia"); | |
cells->GetObjectByIndex(new String("D6"))->PutValue("Europe"); | |
cells->GetObjectByIndex(new String("D7"))->PutValue("Europe"); | |
cells->GetObjectByIndex(new String("D8"))->PutValue("Europe"); | |
cells->GetObjectByIndex(new String("D9"))->PutValue("Europe"); | |
cells->GetObjectByIndex(new String("D10"))->PutValue("Europe"); | |
cells->GetObjectByIndex(new String("D11"))->PutValue("America"); | |
cells->GetObjectByIndex(new String("D12"))->PutValue("America"); | |
cells->GetObjectByIndex(new String("D13"))->PutValue("America"); | |
cells->GetObjectByIndex(new String("D14"))->PutValue("America"); | |
cells->GetObjectByIndex(new String("D15"))->PutValue("America"); | |
cells->GetObjectByIndex(new String("E2"))->PutValue("China"); | |
cells->GetObjectByIndex(new String("E3"))->PutValue("India"); | |
cells->GetObjectByIndex(new String("E4"))->PutValue("Korea"); | |
cells->GetObjectByIndex(new String("E5"))->PutValue("India"); | |
cells->GetObjectByIndex(new String("E6"))->PutValue("France"); | |
cells->GetObjectByIndex(new String("E7"))->PutValue("France"); | |
cells->GetObjectByIndex(new String("E8"))->PutValue("Germany"); | |
cells->GetObjectByIndex(new String("E9"))->PutValue("Italy"); | |
cells->GetObjectByIndex(new String("E10"))->PutValue("France"); | |
cells->GetObjectByIndex(new String("E11"))->PutValue("U.S."); | |
cells->GetObjectByIndex(new String("E12"))->PutValue("U.S."); | |
cells->GetObjectByIndex(new String("E13"))->PutValue("Brazil"); | |
cells->GetObjectByIndex(new String("E14"))->PutValue("U.S."); | |
cells->GetObjectByIndex(new String("E15"))->PutValue("U.S."); | |
cells->GetObjectByIndex(new String("F2"))->PutValue(2000); | |
cells->GetObjectByIndex(new String("F3"))->PutValue(500); | |
cells->GetObjectByIndex(new String("F4"))->PutValue(1200); | |
cells->GetObjectByIndex(new String("F5"))->PutValue(1500); | |
cells->GetObjectByIndex(new String("F6"))->PutValue(500); | |
cells->GetObjectByIndex(new String("F7"))->PutValue(1500); | |
cells->GetObjectByIndex(new String("F8"))->PutValue(800); | |
cells->GetObjectByIndex(new String("F9"))->PutValue(900); | |
cells->GetObjectByIndex(new String("F10"))->PutValue(500); | |
cells->GetObjectByIndex(new String("F11"))->PutValue(1600); | |
cells->GetObjectByIndex(new String("F12"))->PutValue(600); | |
cells->GetObjectByIndex(new String("F13"))->PutValue(2000); | |
cells->GetObjectByIndex(new String("F14"))->PutValue(500); | |
cells->GetObjectByIndex(new String("F15"))->PutValue(900); | |
// Adding a new List Object to the worksheet | |
worksheet->GetIListObjects()->Add(new String("A1"), new String("F15"), true); | |
intrusive_ptr<IListObject> listObject = worksheet->GetIListObjects()->GetObjectByIndex(0); | |
// Adding Default Style to the table | |
listObject->SetTableStyleType(TableStyleType_TableStyleMedium10); | |
// Show Total | |
listObject->SetShowTotals(true); | |
// Saving the Excel file | |
workbook->Save(dataDir_Tables->StringAppend(new String("FormatTable_out.xlsx"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_Worksheets->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Applying freeze panes settings | |
worksheet->FreezePanes(3, 2, 3, 2); | |
// Saving the modified Excel file | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("FreezePanes_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
intrusive_ptr<ICellsHelper> cellsHelper = new ICellsHelper(); | |
String name = cellsHelper->CellIndexToName_i(3, 5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
int row; | |
int column; | |
intrusive_ptr<ICellsHelper> cellsHelper = new ICellsHelper(); | |
cellsHelper->CellNameToIndex_i(new String("C4"), row, column); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Grouping first six rows and first three columns | |
worksheet->GetICells()->GroupRows(0, 5, true); | |
worksheet->GetICells()->GroupColumns(0, 2, true); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("GroupRowsColumns_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Create a new workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
// Get the first worksheet | |
intrusive_ptr<IWorksheetCollection> wsc = wb->GetIWorksheets(); | |
intrusive_ptr<IWorksheet> ws = wsc->GetObjectByIndex(0); | |
// Get cell(0,0) | |
intrusive_ptr<ICells> cells = ws->GetICells(); | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(0, 0); | |
// Write "Hello World" to cell(0,0) of the first sheet | |
intrusive_ptr<String> str = new String("Hello World£¡"); | |
cell->PutValue(str); | |
// Save this workbook to resultFile folder*/ | |
wb->Save(sourcePath->StringAppend(new String("HelloWorld_out.xlsx"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Inserting a column into the worksheet at 2nd position | |
worksheet->GetICells()->InsertColumn(1); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("InsertColumn_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Inserting 10 rows into the worksheet starting from 3rd row | |
worksheet->GetICells()->InsertRows(2, 10); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("InsertMultipleRows_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Inserting a row into the worksheet at 3rd position | |
worksheet->GetICells()->InsertRow(2); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("InsertRow_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(sourcePath->StringAppend(new String("CellsNet41046.xlsx"))); | |
intrusive_ptr<IListObject> listObject = workbook->GetIWorksheets()->GetObjectByIndex(0)->GetIListObjects()->GetObjectByIndex(0); | |
listObject->ApplyStyleToRange(); | |
intrusive_ptr<IStyle> style = workbook->GetIWorksheets()->GetObjectByIndex(0)->GetICells()->GetObjectByIndex(new String("A1"))->GetIStyle(); | |
EXPECT_TRUE((style->GetForegroundColor()->ToArgb() & 0xFFFFFF) == (Color::FromArgb(79, 129, 189)->ToArgb() & 0xFFFFFF)); | |
workbook->GetIWorksheets()->GetObjectByIndex(0)->GetIListObjects()->RemoveAt(0); | |
workbook =Factory::CreateIWorkbook(sourcePath->StringAppend(new String("CellsNet41046.xlsx"))); | |
listObject = workbook->GetIWorksheets()->GetObjectByIndex(0)->GetIListObjects()->GetObjectByIndex(0); | |
listObject->ConvertToRange(); | |
style = workbook->GetIWorksheets()->GetObjectByIndex(0)->GetICells()->GetObjectByIndex(new String("A1"))->GetIStyle(); | |
EXPECT_TRUE((style->GetForegroundColor()->ToArgb() & 0xFFFFFF) == (Color::FromArgb(79, 129, 189)->ToArgb() & 0xFFFFFF)); | |
EXPECT_TRUE(workbook->GetIWorksheets()->GetObjectByIndex(0)->GetIListObjects()->GetCount() == 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Data->StringAppend(new String("Book1.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Get cells from sheet | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
// Access the Maximum Display Range | |
intrusive_ptr<IRange> range = cells->GetMaxDisplayIRange(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Worksheets->StringAppend(new String("Book1.xlsx"))); | |
// Create a Worksheets object with reference to the sheets of the Workbook and get the first worksheet. | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Move the first sheet to the third position in the workbook. | |
worksheet->MoveTo(2); | |
// Save the Excel file. | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("MoveWorksheetsWithinWorkbook_out.xls"))); | |
printf("\nWorksheet moved successfully with in a workbook!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file using its file path | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_LoadingAndSaving->StringAppend(new String("Book1.xlsx"))); | |
printf("\nWorkbook opened successfully using path!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Create a Stream object | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_LoadingAndSaving->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Creating a Workbook object, open the file from a Stream object | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
printf("\nWorkbook opened successfully using stream!"); | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(sourcePath->StringAppend(new String("SG-L-AllInd-Hd+Co-Rank32.xlsx"))); | |
workbook->Save(sourcePath->StringAppend(new String("SG-L-AllInd-Hd+Co-Rank32_out.xlsx"))); | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
EXPECT_TRUE(workbook&&worksheet); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(sourcePath->StringAppend(new String("pagesetup2.xls"))); | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
intrusive_ptr<IPageSetup> pagesetup = worksheet->GetIPageSetup(); | |
// Page | |
EXPECT_TRUE(pagesetup->GetOrientation() == PageOrientationType_Portrait); | |
EXPECT_TRUE(pagesetup->GetZoom() == 105); | |
EXPECT_TRUE(pagesetup->GetPaperSize() == PaperSizeType_PaperA4); | |
EXPECT_TRUE(pagesetup->GetFirstPageNumber() == 1); | |
// Margins | |
EXPECT_TRUE(pagesetup->GetCenterHorizontally()); | |
EXPECT_TRUE(pagesetup->GetCenterVertically()); | |
// Header/Footer | |
EXPECT_TRUE(StringHelperPal::IsNullString(pagesetup->GetHeader(0)));// String("") | |
EXPECT_TRUE(StringHelperPal::IsNullString(pagesetup->GetHeader(1))); | |
EXPECT_TRUE(StringHelperPal::IsNullString(pagesetup->GetHeader(2))); | |
EXPECT_TRUE(StringHelperPal::IsNullString(pagesetup->GetFooter(0))); | |
EXPECT_TRUE(StringHelperPal::IsNullString(pagesetup->GetFooter(1))); | |
EXPECT_TRUE(StringHelperPal::IsNullString(pagesetup->GetFooter(2))); | |
// Sheet | |
EXPECT_TRUE(pagesetup->GetPrintTitleRows()->Equals((StringPtr)new String("$1:$1"))); | |
EXPECT_TRUE(pagesetup->GetPrintGridlines()); | |
EXPECT_TRUE(!pagesetup->GetBlackAndWhite()); | |
EXPECT_TRUE(!pagesetup->GetDraft()); | |
EXPECT_TRUE(pagesetup->GetPrintHeadings()); | |
EXPECT_TRUE(pagesetup->GetPrintComments() == PrintCommentsType_PrintSheetEnd); | |
EXPECT_TRUE(pagesetup->GetPrintErrors() == PrintErrorsType_PrintErrorsNA); | |
EXPECT_TRUE(pagesetup->GetOrder() == PrintOrderType_OverThenDown); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_Worksheets->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Removing a worksheet using its sheet index | |
workbook->GetIWorksheets()->RemoveAt(0); | |
// Save the Excel file. | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("RemoveWorksheetsUsingIndex_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiating a Workbook object and opening the Excel file through the path | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Worksheets->StringAppend(new String("Book1.xlsx"))); | |
// Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Set the active cell | |
worksheet->SetActiveCell(new String("A20")); | |
// Split the worksheet window | |
worksheet->RemoveSplit(); | |
// Saving the modified Excel file | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("RemovingPanes_out.xls"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and load excel file from path | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Data->StringAppend(new String("Book1.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Get cells from sheet | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
for (int i = 0; i < cells->GetCount(); i++) | |
{ | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(i); | |
switch (cell->GetType()) | |
{ | |
// Evaluating the data type of the cell data for string value | |
case CellValueType_IsString: | |
cell->GetStringValue(); | |
break; | |
// Evaluating the data type of the cell data for double value | |
case CellValueType_IsNumeric: | |
cell->GetDoubleValue(); | |
break; | |
// Evaluating the data type of the cell data for boolean value | |
case CellValueType_IsBool: | |
cell->GetBoolValue(); | |
break; | |
// Evaluating the data type of the cell data for date/time value | |
case CellValueType_IsDateTime: | |
cell->GetDateTimeValue(); | |
break; | |
// Evaluating the unknown data type of the cell data | |
case CellValueType_IsUnknown: | |
cell->GetStringValue(); | |
break; | |
default: | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file using its file path | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_LoadingAndSaving->StringAppend(new String("Book1.xlsx"))); | |
// Save in Excel 97 � 2003 format | |
workbook->Save(dataDir_LoadingAndSaving->StringAppend(new String("SavingToSomeLocation_out.xls"))); | |
// OR | |
workbook->Save(dataDir_LoadingAndSaving->StringAppend(new String("SavingToSomeLocation_out.xls")), SaveFormat_Excel97To2003); | |
// Save in Excel2007 xlsx format | |
workbook->Save(dataDir_LoadingAndSaving->StringAppend(new String("SavingToSomeLocation_out.xlsx")), SaveFormat_Xlsx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file using its file path | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_LoadingAndSaving->StringAppend(new String("Book1.xlsx"))); | |
intrusive_ptr<FileStream> stream = new FileStream(dataDir_LoadingAndSaving->StringAppend(new String("SavingToStream_out.xlsx")), FileMode_CreateNew); | |
workbook->Save(stream, SaveFormat_Xlsx); | |
stream->Close(); | |
printf("\nFile saved successfully to a stream!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Tables->StringAppend(new String("source.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Get the List objects collection in the first worksheet. | |
intrusive_ptr<IListObjectCollection> listObjects = worksheet->GetIListObjects(); | |
// Set the comment of the first list object | |
listObjects->GetObjectByIndex(0)->SetComment(new String("This is Aspose.Cells comment.")); | |
// Saving the Excel file | |
workbook->Save(dataDir_Tables->StringAppend(new String("SetCommentOfTableOrListObject_out.xlsx")), SaveFormat_Xlsx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Create a new workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
// Get the first worksheet | |
intrusive_ptr<IWorksheetCollection> wsc = wb->GetIWorksheets(); | |
intrusive_ptr<IWorksheet> ws = wsc->GetObjectByIndex(0); | |
// Get cells | |
intrusive_ptr<ICells> cells = ws->GetICells(); | |
// Set value to cell(0,0) and cell(1,0) | |
cells->GetObjectByIndex(0, 0)->PutValue(3); | |
cells->GetObjectByIndex(1, 0)->PutValue(2); | |
// Set Formula | |
cells->GetObjectByIndex(0, 1)->SetFormula(new String("=SUM(A1,A2)")); | |
// Save this workbook to resultFile | |
wb->Save(sourcePath->StringAppend(new String("SetFormula_out.xlsx"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Setting the height of the second row to 13 | |
worksheet->GetICells()->SetRowHeight(1, 13); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("SetRowHeight_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Create a new workbook and get the first worksheet | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
// Get cells style | |
intrusive_ptr<IStyle> style = ws->GetICells()->GetIStyle(); | |
// Set font color | |
style->GetIFont()->SetColor(Color::GetGreen()); | |
// Set Background | |
style->SetPattern(BackgroundType::BackgroundType_Gray12); | |
style->SetBackgroundColor(Color::GetRed()); | |
// Set Border | |
style->SetBorder((BorderType_LeftBorder), CellBorderType_Thin, Color::GetBlue()); | |
style->SetBorder((BorderType_RightBorder), CellBorderType_Double, Color::GetGold()); | |
// Set string value to cell 'A1' | |
intrusive_ptr<ICells> cells = ws->GetICells(); | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(new String("A1")); | |
cell->PutValue((StringPtr)new String("Text")); | |
// Apply style to cell 'A1' | |
cell->SetStyle(style); | |
// Save this workbook to resultFile | |
wb->Save(sourcePath->StringAppend(new String("SetStyle_out.xlsx"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Setting the height of all rows in the worksheet to 15 | |
worksheet->GetICells()->SetStandardHeight(15); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("SettingAllRowsHeight_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Setting the width of the second column to 17.5 | |
worksheet->GetICells()->SetColumnWidth(1, 17.5); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("SettingColumWidth_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Setting the width of all columns in the worksheet to 20.5 | |
worksheet->GetICells()->SetStandardWidth(20.5); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("SettingWidthOfAllColumns_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_Worksheets->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Setting the zoom factor of the worksheet to 75 | |
worksheet->SetZoom(75); | |
// Saving the modified Excel file | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("SetZoomFactor_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiating a Workbook object and opening the Excel file through the path | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Worksheets->StringAppend(new String("Book1.xlsx"))); | |
// Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Set the active cell | |
worksheet->SetActiveCell(new String("A20")); | |
// Split the worksheet window | |
worksheet->Split(); | |
// Saving the modified Excel file | |
workbook->Save(dataDir_Worksheets->StringAppend(new String("FreezePanes_out.xls"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr samplePrecedentsAndDependents = dirPath->StringAppend(new String("samplePrecedentsAndDependents.xlsx")); | |
//Load source Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(samplePrecedentsAndDependents); | |
//Calculate workbook formula | |
workbook->CalculateFormula(); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Access cell F6 | |
intrusive_ptr<ICell> cell = worksheet->GetICells()->GetObjectByIndex(new String("F6")); | |
//Get dependents of the cells and print them on console | |
Console::Write(new String("Printing Dependents of Cell: ")); | |
Console::Write(cell->GetName()); | |
Console::WriteLine(new String("")); | |
Console::WriteLine(new String("-------------------------------")); | |
//Parameter false means we do not want to search other sheets | |
intrusive_ptr<Aspose::Cells::Systems::Array1D<ICell*>> depCells = cell->GetDependentICells(false); | |
//Get the length of the array | |
int len = depCells->Length(); | |
//Print the names of all the cells inside the array | |
for (int i = 0; i < len; i++) | |
{ | |
intrusive_ptr<ICell> dCell = depCells->At(i); | |
Console::WriteLine(dCell->GetName()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr samplePrecedentsAndDependents = dirPath->StringAppend(new String("samplePrecedentsAndDependents.xlsx")); | |
//Load source Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(samplePrecedentsAndDependents); | |
//Calculate workbook formula | |
workbook->CalculateFormula(); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Access cell F6 | |
intrusive_ptr<ICell> cell = worksheet->GetICells()->GetObjectByIndex(new String("F6")); | |
//Get precedents of the cells and print them on console | |
Console::Write(new String("Printing Precedents of Cell: ")); | |
Console::Write(cell->GetName()); | |
Console::WriteLine(new String("")); | |
Console::WriteLine(new String("-------------------------------")); | |
intrusive_ptr<IReferredAreaCollection> refac = cell->GetIPrecedents(); | |
int count = refac->GetCount(); | |
for (int i = 0; i < count; i++) | |
{ | |
intrusive_ptr<IReferredArea> refa = refac->GetObjectByIndex(i); | |
int row = refa->GetStartRow(); | |
int col = refa->GetStartColumn(); | |
cell = worksheet->GetICells()->GetICell(row,col); | |
Console::WriteLine(cell->GetName()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Creating a file stream containing the Excel file to be opened | |
intrusive_ptr<FileStream> fstream = new FileStream(dataDir_RowsAndColumns->StringAppend(new String("Book1.xlsx")), FileMode_Open); | |
// Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// UnGrouping first six rows and first three columns | |
worksheet->GetICells()->UngroupRows(0, 5); | |
worksheet->GetICells()->UngroupColumns(0, 2); | |
// Save the Excel file. | |
workbook->Save(dataDir_RowsAndColumns->StringAppend(new String("UngroupRowsAndColumns_out.xls"))); | |
// Closing the file stream to free all resources | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Data->StringAppend(new String("Book1.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Get cells from sheet | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
// Accessing a cell using its name | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(new String("A1")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Implement ICustomFunction interface | |
class CustomFunction : public ICustomFunction | |
{ | |
public: | |
//Evalaute and return the values of your custom functions | |
intrusive_ptr<Aspose::Cells::System::Object> | |
CalculateCustomFunction( | |
intrusive_ptr<Aspose::Cells::System::String> functionName, | |
intrusive_ptr<Aspose::Cells::System::Collections::ArrayList> paramsList, | |
intrusive_ptr<Aspose::Cells::System::Collections::ArrayList> contextObjects) | |
{ | |
if (functionName->Equals(new String("MySampleFunc"))) | |
{ | |
return new String("MY sample function was called successfully."); | |
} | |
if (functionName->Equals(new String("YourSampleFunc"))) | |
{ | |
return new String("YOUR sample function was called successfully."); | |
} | |
return NULL; | |
} | |
}; | |
void RunUsingICustomFunctionFeature() | |
{ | |
//Create workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet in the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Adding custom formulas to Cell A1 and A2 | |
ws->GetICells()->GetObjectByIndex(new String("A1"))->SetFormula(new String("=MySampleFunc()")); | |
ws->GetICells()->GetObjectByIndex(new String("A2"))->SetFormula(new String("=YourSampleFunc()")); | |
// Calcualting Formulas | |
intrusive_ptr<CustomFunction> custFunc = new CustomFunction(); | |
wb->CalculateFormula(false, custFunc); | |
//Print the value of cell A1 and A2 after the calculation of custom function implemented by us. | |
intrusive_ptr<String> valA1 = ws->GetICells()->GetObjectByIndex(new String("A1"))->GetStringValue(); | |
intrusive_ptr<String> valA2 = ws->GetICells()->GetObjectByIndex(new String("A2"))->GetStringValue(); | |
//Print the values on console | |
printf("Value of A1: %s\r\n", valA1->charValue()); | |
printf("Value of A2: %s\r\n", valA2->charValue()); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Data->StringAppend(new String("Book1.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Get cells from sheet | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
// Accessing a cell using its index | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Create a new workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
// Get the first worksheet | |
intrusive_ptr<IWorksheetCollection> wsc = wb->GetIWorksheets(); | |
intrusive_ptr<IWorksheet> ws = wsc->GetObjectByIndex(0); | |
// Get cells | |
intrusive_ptr<ICells> cells = ws->GetICells(); | |
// Get cell(0,0) | |
intrusive_ptr<ICell> cell0 = cells->GetObjectByIndex(0, 0); | |
// Set DatetTime value to cell(0,0) | |
cell0->PutValue((DateTimePtr)new DateTime(2000, 1, 1)); | |
// Check value | |
EXPECT_TRUE(cell0->GetDateTimeValue()->Equals((DateTimePtr)new DateTime(2000, 1, 1))); | |
// Get cell(1,0) | |
intrusive_ptr<ICell> cell1 = cells->GetObjectByIndex(1, 0); | |
// Set string type value to cell(1,0) | |
cell1->PutValue((StringPtr)new String("20000101")); | |
// Check value | |
EXPECT_TRUE(cell1->GetStringValue()->Equals((StringPtr)new String("20000101"))); | |
// Get cell(2,0) | |
intrusive_ptr<ICell> cell2 = cells->GetObjectByIndex(2, 0); | |
// Set double type value to cell(2,0) | |
cell2->PutValue(20000101.01); | |
// Check value | |
EXPECT_TRUE(cell2->GetDoubleValue() == 20000101.01); | |
// Get cell(3,0) | |
intrusive_ptr<ICell> cell3 = cells->GetObjectByIndex(3, 0); | |
// Set int type value to cell(3,0) | |
cell3->PutValue(20000101); | |
// Check value | |
EXPECT_TRUE(cell3->GetIntValue() == 20000101); | |
// Get cell(4,0) | |
intrusive_ptr<ICell> cell4 = cells->GetObjectByIndex(4, 0); | |
// Set bool type value to cell(4,0) | |
cell4->PutValue(true); | |
// Check value | |
EXPECT_TRUE(cell4->GetBoolValue() == true); | |
// Save this workbook to resultFile | |
wb->Save(sourcePath->StringAppend(new String("ValueType_out.xlsx"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
void AddingFormulasandCalculatingResults() | |
{ | |
//Create workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet in the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Adding integer values to cells A1, A2 and A3 | |
ws->GetICells()->GetObjectByIndex(new String("A1"))->PutValue(10); | |
ws->GetICells()->GetObjectByIndex(new String("A2"))->PutValue(20); | |
ws->GetICells()->GetObjectByIndex(new String("A3"))->PutValue(70); | |
//Adding a SUM formula to "A4" cell | |
ws->GetICells()->GetObjectByIndex(new String("A4"))->SetFormula(new String("=SUM(A1:A3)")); | |
//Calculating the results of formulas | |
wb->CalculateFormula(); | |
//Get the calculated value of the cell | |
intrusive_ptr<String> strVal = ws->GetICells()->GetObjectByIndex(new String("A4"))->GetStringValue(); | |
//Print the calculated value on console | |
printf("Calculated Result: %s", strVal->charValue()); | |
//Saving the workbook | |
wb->Save(dirPath->StringAppend(new String("outputAddingFormulasCalculatingResults.xlsx"))); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
void DirectCalculationofFormula() | |
{ | |
//Create workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet in the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Put 20 in cell A1 | |
intrusive_ptr<ICell> cellA1 = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
cellA1->PutValue(20); | |
//Put 30 in cell A2 | |
intrusive_ptr<ICell> cellA2 = ws->GetICells()->GetObjectByIndex(new String("A2")); | |
cellA2->PutValue(30); | |
//Calculate the Sum of A1 and A2 | |
intrusive_ptr<Aspose::Cells::System::Object> results = ws->CalculateFormula(new String("=Sum(A1:A2)")); | |
//Print the output | |
printf("Value of A1: %s\r\n", cellA1->GetStringValue()->charValue()); | |
printf("Value of A2: %s\r\n", cellA2->GetStringValue()->charValue()); | |
printf("Result of Sum(A1:A2): %s\r\n", results->ToString()->charValue()); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
void CalculatingFormulasOnceOnly() | |
{ | |
//Create workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(dirPath->StringAppend(new String("sampleCalculatingFormulasOnceOnly.xlsx"))); | |
//Set the CreateCalcChain as false | |
wb->GetISettings()->SetCreateCalcChain(false); | |
//Get the time in milliseconds before formula calculation | |
int before_miliseconds = Aspose::Cells::System::DateTime::GetNow()->GetMillisecond(); | |
//Calculate the workbook formulas | |
wb->CalculateFormula(); | |
//Get the time in milliseconds after formula calculation | |
int after_miliseconds = Aspose::Cells::System::DateTime::GetNow()->GetMillisecond(); | |
//Print the difference in milliseconds | |
printf("Workbook Formula Calculation Elapsed Time in Milliseconds: %d\r\n\r\n", after_miliseconds - before_miliseconds); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleData = dirPath->StringAppend(new String("sampleData.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleData); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Get cells from sheet | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
//Accessing a cell using its name | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(new String("B3")); | |
//Write string value of the cell on console | |
Console::Write(new String("Value of cell B3: ")); | |
Console::WriteLine(cell->GetStringValue()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleData = dirPath->StringAppend(new String("sampleData.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleData); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Get cells from sheet | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
//Accessing cell B3 using its row and column index | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(2, 1); | |
//Write string value of the cell on console | |
Console::Write(new String("Value of cell B3: ")); | |
Console::WriteLine(cell->GetStringValue()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleData = dirPath->StringAppend(new String("sampleData.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleData); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Get cells from sheet | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
//Access the Maximum Display Range | |
intrusive_ptr<IRange> range = cells->GetMaxDisplayIRange(); | |
//Print string value of the cell on console | |
Console::Write(new String("Maximum Display Range of Worksheet: ")); | |
Console::WriteLine(range->GetRefersTo()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleData = dirPath->StringAppend(new String("sampleData.xlsx")); | |
//Path of output excel file | |
StringPtr outputData = outPath->StringAppend(new String("outputData.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleData); | |
//Accessing the second worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(1); | |
//Adding a string value to the cell | |
worksheet->GetICells()->GetObjectByIndex(new String("A1"))->PutValue("Hello World"); | |
//Adding a double value to the cell | |
worksheet->GetICells()->GetObjectByIndex(new String("A2"))->PutValue(20.5); | |
//Adding an integer value to the cell | |
worksheet->GetICells()->GetObjectByIndex(new String("A3"))->PutValue(15); | |
//Adding a boolean value to the cell | |
worksheet->GetICells()->GetObjectByIndex(new String("A4"))->PutValue(true); | |
//Setting the display format of the date | |
intrusive_ptr<ICell> cell = worksheet->GetICells()->GetObjectByIndex(new String("A5")); | |
intrusive_ptr<IStyle> style = cell->GetIStyle(); | |
style->SetNumber(15); | |
cell->SetIStyle(style); | |
//Save the workbook | |
workbook->Save(outputData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleData = dirPath->StringAppend(new String("sampleData.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleData); | |
//Accessing the third worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(2); | |
//Get cells from sheet | |
intrusive_ptr<ICells> cells = worksheet->GetICells(); | |
//Variable declarations | |
intrusive_ptr<String> strVal; | |
intrusive_ptr<Aspose::Cells::System::DateTime> dateVal; | |
Aspose::Cells::System::Double dblVal; | |
Aspose::Cells::System::Boolean boolVal; | |
for (int i = 0; i < cells->GetCount(); i++) | |
{ | |
intrusive_ptr<ICell> cell = cells->GetObjectByIndex(i); | |
switch (cell->GetType()) | |
{ | |
//Evaluating the data type of the cell data for string value | |
case CellValueType_IsString: | |
Console::WriteLine(new String("Cell Value Type Is String.")); | |
strVal = cell->GetStringValue(); | |
break; | |
//Evaluating the data type of the cell data for double value | |
case CellValueType_IsNumeric: | |
Console::WriteLine(new String("Cell Value Type Is Numeric.")); | |
dblVal = cell->GetDoubleValue(); | |
break; | |
//Evaluating the data type of the cell data for boolean value | |
case CellValueType_IsBool: | |
Console::WriteLine(new String("Cell Value Type Is Bool.")); | |
boolVal = cell->GetBoolValue(); | |
break; | |
//Evaluating the data type of the cell data for date/time value | |
case CellValueType_IsDateTime: | |
Console::WriteLine(new String("Cell Value Type Is DateTime.")); | |
dateVal = cell->GetDateTimeValue(); | |
break; | |
//Evaluating the unknown data type of the cell data | |
case CellValueType_IsUnknown: | |
cell->GetStringValue(); | |
break; | |
default: | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of output excel file | |
StringPtr outputAddHyperlinksToTheCells = outPath->StringAppend(new String("outputAddHyperlinksToTheCells.xlsx")); | |
//Create a new workbook | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(); | |
//Get the first worksheet | |
intrusive_ptr<IWorksheetCollection> wsc = workbook->GetIWorksheets(); | |
intrusive_ptr<IWorksheet> ws = wsc->GetObjectByIndex(0); | |
//Add hyperlink in cell C7 and make use of its various methods | |
intrusive_ptr<IHyperlinkCollection> hypLnks = ws->GetIHyperlinks(); | |
int idx = hypLnks->Add(new String("C7"), 1, 1, new String("http://www.aspose.com/")); | |
intrusive_ptr<IHyperlink> lnk = hypLnks->GetObjectByIndex(idx); | |
lnk->SetTextToDisplay(new String("Aspose")); | |
lnk->SetScreenTip(new String("Link to Aspose Website")); | |
//Save the workbook | |
workbook->Save(outputAddHyperlinksToTheCells); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of output excel file | |
StringPtr outputApplyConditionalFormattingInWorksheet = outPath->StringAppend(new String("outputApplyConditionalFormattingInWorksheet.xlsx")); | |
//Create an empty workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Adds an empty conditional formatting | |
int idx = ws->GetIConditionalFormattings()->Add(); | |
intrusive_ptr<IFormatConditionCollection> fcs = ws->GetIConditionalFormattings()->GetObjectByIndex(idx); | |
//Set the conditional format range | |
intrusive_ptr<ICellArea> ca = ICellArea::CreateICellArea(new String("A1"), new String("A1")); | |
fcs->AddArea(ca); | |
ca = ICellArea::CreateICellArea(new String("B2"), new String("B2")); | |
fcs->AddArea(ca); | |
//Add condition and set the background color | |
idx = fcs->AddCondition(FormatConditionType_CellValue, OperatorType_Between, new String("=A2"), new String("100")); | |
intrusive_ptr<IFormatCondition> fc = fcs->GetObjectByIndex(idx); | |
fc->GetIStyle()->SetBackgroundColor(Systems::Drawing::Color::GetRed()); | |
//User friendly message to test the output excel file. | |
StringPtr msgStr = new String("Red color in cells A1 and B2 is because of Conditional Formatting. Put 101 or any value >100 in cell A2 and B2, you will see Red background color will be gone."); | |
ws->GetICells()->GetObjectByIndex(new String("A10"))->PutValue(msgStr); | |
//Save the output excel file | |
wb->Save(outputApplyConditionalFormattingInWorksheet); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of output excel file | |
StringPtr outputFormatCellOrRangeOfCells = outPath->StringAppend(new String("outputFormatCellOrRangeOfCells.xlsx")); | |
//Create a new workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Get first worksheet which is created by default | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Access cell C4 by cell name | |
intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("C4")); | |
//Add some text in cell | |
cell->PutValue((StringPtr)new String("This is sample data.")); | |
//Access the cell style | |
intrusive_ptr<IStyle> st = cell->GetIStyle(); | |
//Fille the cell color to Yellow | |
st->SetPattern(BackgroundType_Solid); | |
st->SetForegroundColor(Systems::Drawing::Color::GetYellow()); | |
//Set the text to wrapp | |
st->SetTextWrapped(true); | |
//Set the left and right border to Red | |
st->SetBorder(BorderType_LeftBorder, CellBorderType_Thick, Systems::Drawing::Color::GetRed()); | |
st->SetBorder(BorderType_RightBorder, CellBorderType_Thick, Systems::Drawing::Color::GetRed()); | |
//Set font color, font size, strike, bold, italic | |
st->GetIFont()->SetColor(Systems::Drawing::Color::GetBlue()); | |
st->GetIFont()->SetSize(16); | |
st->GetIFont()->SetStrikeType(TextStrikeType_Single); | |
st->GetIFont()->SetBold(true); | |
st->GetIFont()->SetItalic(true); | |
//Set text horizontal and vertical alignment to center | |
st->SetHorizontalAlignment(TextAlignmentType_Center); | |
st->SetVerticalAlignment(TextAlignmentType_Center); | |
//Set the cell style | |
cell->SetIStyle(st); | |
//Set the cell column width and row height | |
ws->GetICells()->SetColumnWidth(cell->GetColumn(), 20); | |
ws->GetICells()->SetRowHeight(cell->GetRow(), 70); | |
//Save the output excel file | |
wb->Save(outputFormatCellOrRangeOfCells); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of output excel file | |
StringPtr outputCreateNamedRange = dirPath->StringAppend(new String("outputCreateNamedRange.xlsx")); | |
//Create a workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Create a range | |
intrusive_ptr<IRange> rng = ws->GetICells()->CreateIRange((intrusive_ptr<String>)new String("A5:C10")); | |
//Set its name to make it named range | |
rng->SetName((intrusive_ptr<String>)new String("MyNamedRange")); | |
//Read the named range created above from names collection | |
intrusive_ptr<IName> nm = wb->GetIWorksheets()->GetINames()->GetObjectByIndex(0); | |
//Print its FullText and RefersTo memebers | |
StringPtr fullTect = new String("Full Text : "); | |
Console::WriteLine(fullTect->StringAppend(nm->GetFullText())); | |
StringPtr referTo = new String("Refers To: "); | |
Console::WriteLine(referTo->StringAppend(nm->GetRefersTo())); | |
//Save the workbook in xlsx format | |
wb->Save(outputCreateNamedRange, SaveFormat_Xlsx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleCreatingSubtotals = dirPath->StringAppend(new String("sampleCreatingSubtotals.xlsx")); | |
//Path of output excel file | |
StringPtr outputCreatingSubtotals = outPath->StringAppend(new String("outputCreatingSubtotals.xlsx")); | |
//Load sample excel file into a workbook object | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleCreatingSubtotals); | |
//Get first worksheet of the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Get the cells collection of the worksheet | |
intrusive_ptr<ICells> cells = ws->GetICells(); | |
//Create cell area covering the cell range B3:C19 | |
intrusive_ptr<ICellArea> ca = ICellArea::CreateICellArea(new String("B3"), new String("C19")); | |
//Create integer array of size 1 and set its first value to 1 | |
intrusive_ptr<Array1D<int>> totalList = new Array1D<int>(1); | |
totalList->SetValue(1, 0); | |
//Apply subtotal, the consolidation function is Sum and it will be applied to second column | |
cells->Subtotal(ca, 0, ConsolidationFunction_Sum, totalList); | |
//Save the workbook in xlsx format | |
wb->Save(outputCreatingSubtotals); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleFindOrSearchData = dirPath->StringAppend(new String("sampleFindOrSearchData.xlsx")); | |
//Load sample excel file into a workbook object | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleFindOrSearchData); | |
//Get first worksheet of the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Finding the cell containing the number 80 | |
intrusive_ptr<ICell> cell = ws->GetICells()->FindNumber(80, NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str1 = new String(L"Name of the cell containing the number 80: "); | |
Console::WriteLine(str1->StringAppend(cell->GetName())); | |
//Finding the cell containing the specified formula | |
cell = ws->GetICells()->FindFormula(new String("=SUM(A5:A10)"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str2 = new String(L"Name of the cell containing formula =SUM(A5:A10): "); | |
Console::WriteLine(str2->StringAppend(cell->GetName())); | |
//Finding the cell containing the formula that contains CHA | |
cell = ws->GetICells()->FindFormulaContains(new String("CHA"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str3 = new String(L"Name of the cell containing the formula that contains CHA: "); | |
Console::WriteLine(str3->StringAppend(cell->GetName())); | |
//Finding the cell containing the specified string | |
cell = ws->GetICells()->FindString(new String("SampleData"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str4 = new String(L"Name of the cell containing specified string: "); | |
Console::WriteLine(str4->StringAppend(cell->GetName())); | |
//Finding the cell containing the string that contains Two | |
cell = ws->GetICells()->FindStringContains(new String("Two"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str5 = new String(L"Name of the cell containing the string that contains Two: "); | |
Console::WriteLine(str5->StringAppend(cell->GetName())); | |
//Finding the cell containing the string that starts with AAA | |
cell = ws->GetICells()->FindStringStartsWith(new String("AAA"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str6 = new String(L"Name of the cell containing the string that starts with AAA: "); | |
Console::WriteLine(str6->StringAppend(cell->GetName())); | |
//Finding the cell containing the string that ends with BBB | |
cell = ws->GetICells()->FindStringEndsWith(new String("BBB"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str7 = new String(L"Name of the cell containing the string that ends with BBB: "); | |
Console::WriteLine(str7->StringAppend(cell->GetName())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleManipulateNamedRangeInWorkbook = dirPath->StringAppend(new String("sampleManipulateNamedRangeInWorkbook.xlsx")); | |
//Path of output excel file | |
StringPtr outputManipulateNamedRangeInWorkbook = outPath->StringAppend(new String("outputManipulateNamedRangeInWorkbook.xlsx")); | |
//Create a workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleManipulateNamedRangeInWorkbook); | |
//Read the named range created above from names collection | |
intrusive_ptr<IName> nm = wb->GetIWorksheets()->GetINames()->GetObjectByIndex(0); | |
//Print its FullText and RefersTo members | |
StringPtr fullTect = new String("Full Text : "); | |
Console::WriteLine(fullTect->StringAppend(nm->GetFullText())); | |
StringPtr referTo = new String("Refers To : "); | |
Console::WriteLine(referTo->StringAppend(nm->GetRefersTo())); | |
//Manipulate the RefersTo property of NamedRange | |
nm->SetRefersTo((intrusive_ptr<String>)new String("=Sheet1!$D$5:$J$10")); | |
//Save the workbook in xlsx format | |
wb->Save(outputManipulateNamedRangeInWorkbook, SaveFormat_Xlsx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Create a new workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Get first worksheet which is created by default | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Adding a value to "A1" cell | |
intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
cell->PutValue(5); | |
//Adding a value to "A2" cell | |
cell = ws->GetICells()->GetObjectByIndex(new String("A2")); | |
cell->PutValue(15); | |
//Adding a value to "A3" cell | |
cell = ws->GetICells()->GetObjectByIndex(new String("A3")); | |
cell->PutValue(25); | |
//Adding SUM formula to "A4" cell | |
cell = ws->GetICells()->GetObjectByIndex(new String("A4")); | |
cell->SetFormula(new String("=SUM(A1:A3)")); | |
//Calculating the results of formulas | |
wb->CalculateFormula(); | |
//Get the calculated value of the cell "A4" and print it on console | |
cell = ws->GetICells()->GetObjectByIndex(new String("A4")); | |
StringPtr sCalcuInfo = new String(L"Calculated Value of Cell A4: "); | |
Console::WriteLine(sCalcuInfo->StringAppend(cell->GetStringValue())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Implement ICustomFunction interface | |
class CustomFunction : public ICustomFunction | |
{ | |
public: | |
//Evalaute and return the values of your custom functions | |
intrusive_ptr<Aspose::Cells::Systems::Object> | |
CalculateCustomFunction( | |
intrusive_ptr<Aspose::Cells::Systems::String> functionName, | |
intrusive_ptr<Aspose::Cells::Systems::Collections::ArrayList> paramsList, | |
intrusive_ptr<Aspose::Cells::Systems::Collections::ArrayList> contextObjects) | |
{ | |
if (functionName->Equals(new String("MySampleFunc"))) | |
{ | |
return new String("MY sample function was called successfully."); | |
} | |
if (functionName->Equals(new String("YourSampleFunc"))) | |
{ | |
return new String("YOUR sample function was called successfully."); | |
} | |
return NULL; | |
} | |
}; | |
//Using ICustomFunction Feature | |
void UsingICustomFunctionFeature() | |
{ | |
//Create workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet in the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Adding custom formulas to Cell A1 and A2 | |
ws->GetICells()->GetObjectByIndex(new String("A1"))->SetFormula(new String("=MySampleFunc()")); | |
ws->GetICells()->GetObjectByIndex(new String("A2"))->SetFormula(new String("=YourSampleFunc()")); | |
// Calcualting Formulas | |
intrusive_ptr<CustomFunction> custFunc = new CustomFunction(); | |
wb->CalculateFormula(false, custFunc); | |
//Print the value of cell A1 and A2 after the calculation of custom function implemented by us. | |
intrusive_ptr<String> valA1 = ws->GetICells()->GetObjectByIndex(new String("A1"))->GetStringValue(); | |
intrusive_ptr<String> valA2 = ws->GetICells()->GetObjectByIndex(new String("A2"))->GetStringValue(); | |
//Print the values on console | |
StringPtr str1 = new String("Value of A1: "); | |
Console::WriteLine(str1->StringAppend(valA1)); | |
StringPtr str2 = new String("Value of A2: "); | |
Console::WriteLine(str2->StringAppend(valA2)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of output excel file | |
StringPtr outputAddingFormulasAndCalculatingResults = outPath->StringAppend(new String("outputAddingFormulasAndCalculatingResults.xlsx")); | |
//Create workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet in the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Adding integer values to cells A1, A2 and A3 | |
ws->GetICells()->GetObjectByIndex(new String("A1"))->PutValue(10); | |
ws->GetICells()->GetObjectByIndex(new String("A2"))->PutValue(20); | |
ws->GetICells()->GetObjectByIndex(new String("A3"))->PutValue(70); | |
//Adding a SUM formula to "A4" cell | |
ws->GetICells()->GetObjectByIndex(new String("A4"))->SetFormula(new String("=SUM(A1:A3)")); | |
//Calculating the results of formulas | |
wb->CalculateFormula(); | |
//Get the calculated value of the cell | |
intrusive_ptr<String> strVal = ws->GetICells()->GetObjectByIndex(new String("A4"))->GetStringValue(); | |
//Print the calculated value on console | |
StringPtr str1 = new String("Calculated Result: "); | |
Console::WriteLine(str1->StringAppend(strVal)); | |
//Saving the workbook | |
wb->Save(outputAddingFormulasAndCalculatingResults); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\Formulas\\"); | |
//Path of input excel file | |
StringPtr sampleCalculatingFormulasOnceOnly = dirPath->StringAppend(new String("sampleCalculatingFormulasOnceOnly.xlsx")); | |
//Create workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleCalculatingFormulasOnceOnly); | |
//Set the CreateCalcChain as false | |
wb->GetISettings()->SetCreateCalcChain(false); | |
//Get the time in milliseconds before formula calculation | |
int before_miliseconds = Aspose::Cells::Systems::DateTime::GetNow()->GetMillisecond(); | |
//Calculate the workbook formulas | |
wb->CalculateFormula(); | |
//Get the time in milliseconds after formula calculation | |
int after_miliseconds = Aspose::Cells::Systems::DateTime::GetNow()->GetMillisecond(); | |
//Print the difference in milliseconds | |
StringPtr str1 = new String("Workbook Formula Calculation Elapsed Time in Milliseconds: "); | |
Console::WriteLine(str1->StringAppend(Int32Helper::ToString(after_miliseconds - before_miliseconds))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Create workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet in the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Put 20 in cell A1 | |
intrusive_ptr<ICell> cellA1 = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
cellA1->PutValue(20); | |
//Put 30 in cell A2 | |
intrusive_ptr<ICell> cellA2 = ws->GetICells()->GetObjectByIndex(new String("A2")); | |
cellA2->PutValue(30); | |
//Calculate the Sum of A1 and A2 | |
intrusive_ptr<Aspose::Cells::Systems::Object> results = ws->CalculateFormula(new String("=Sum(A1:A2)")); | |
//Print the output | |
StringPtr str1 = new String("Value of A1: "); | |
Console::WriteLine(str1->StringAppend(cellA1->GetStringValue())); | |
StringPtr str2 = new String("Value of A2: "); | |
Console::WriteLine(str2->StringAppend(cellA2->GetStringValue())); | |
StringPtr str3 = new String("Result of Sum(A1:A2): "); | |
Console::WriteLine(str3->StringAppend(results->ToString())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Paths of source and output excel files | |
StringPtr samplePath = dirPath->StringAppend(new String(L"sampleManagingDocumentProperties.xlsx")); | |
StringPtr outputPath = outPath->StringAppend(new String(L"outputManagingDocumentProperties.xlsx")); | |
//Load the sample excel file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(samplePath); | |
//Read built-in title and subject properties | |
StringPtr strTitle = wb->GetIBuiltInDocumentProperties()->GetTitle(); | |
StringPtr strSubject = wb->GetIBuiltInDocumentProperties()->GetSubject(); | |
StringPtr title = new String("Title: "); | |
Console::WriteLine(title->StringAppend(strTitle)); | |
StringPtr subject = new String("Subject: "); | |
Console::WriteLine(subject->StringAppend(strSubject)); | |
//Modify built-in title and subject properties | |
strTitle = new String("Aspose.Cells New Title"); | |
strSubject = new String("Aspose.Cells New Subject"); | |
wb->GetIBuiltInDocumentProperties()->SetTitle(strTitle); | |
wb->GetIBuiltInDocumentProperties()->SetSubject(strSubject); | |
//Read the custom property | |
StringPtr strCustomPropName = new String("MyCustom1"); | |
StringPtr strCustomPropValue = wb->GetICustomDocumentProperties()->GetObjectByIndex(strCustomPropName)->ToString(); | |
StringPtr myCustom1 = new String("\r\nMyCustom1: "); | |
Console::WriteLine(myCustom1->StringAppend(strCustomPropValue)); | |
//Add a new custom property | |
strCustomPropName = new String("MyCustom5"); | |
strCustomPropValue = new String("This is my custom five."); | |
wb->GetICustomDocumentProperties()->AddIDocumentProperty(strCustomPropName, strCustomPropValue); | |
//Save the output excel file | |
wb->Save(outputPath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Create Workbook object from an Excel file path | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(dirPath->StringAppend(new String("sampleExcelFile.xlsx"))); | |
//Show following message on console | |
Console::WriteLine(new String("Workbook opened successfully using file path.")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Create a Stream object | |
intrusive_ptr<FileStream> fstream = new FileStream(dirPath->StringAppend(new String("sampleExcelFile.xlsx")), FileMode_Open); | |
//Create Workbook object from a Stream object | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(fstream); | |
//Show following message on console | |
Console::WriteLine(new String("Workbook opened successfully using stream.")); | |
//Close the Stream object | |
fstream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of input csv file | |
StringPtr srcReadWriteCSV = dirPath->StringAppend(new String(L"srcReadWriteCSV.csv")); | |
//Path of output csv file | |
StringPtr outReadWriteCSV = outPath->StringAppend(new String(L"outReadWriteCSV.csv")); | |
//Read source csv file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(srcReadWriteCSV); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Access cell A1 | |
intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
//Get the string value of cell A1 | |
StringPtr strVal = cell->GetStringValue(); | |
//Print the string value of cell A1 | |
StringPtr cellValue = new String("Cell Value: "); | |
Console::WriteLine(cellValue->StringAppend(strVal)); | |
//Access cell C4 | |
cell = ws->GetICells()->GetObjectByIndex(new String("C4")); | |
//Put the string value of cell A1 into C4 | |
intrusive_ptr<String> strValPtr = new String(strVal); | |
cell->PutValue(strValPtr); | |
//Save the workbook in csv format | |
wb->Save(outReadWriteCSV, SaveFormat_CSV); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of input tab delimited file | |
StringPtr srcReadWriteTabDelimited = dirPath->StringAppend(new String(L"srcReadWriteTabDelimited.txt")); | |
//Path of output tab delimited file | |
StringPtr outReadWriteTabDelimited = outPath->StringAppend(new String(L"outReadWriteTabDelimited.txt")); | |
//Read source tab delimited file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(srcReadWriteTabDelimited); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Access cell A1 | |
intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
//Get the string value of cell A1 | |
StringPtr strVal = cell->GetStringValue(); | |
//Print the string value of cell A1 | |
StringPtr cellValue = new String("Cell Value: "); | |
Console::WriteLine(cellValue->StringAppend(strVal)); | |
//Access cell C4 | |
cell = ws->GetICells()->GetObjectByIndex(new String("C4")); | |
//Put the string value of cell A1 into C4 | |
intrusive_ptr<String> strValPtr = new String(strVal); | |
cell->PutValue(strValPtr); | |
//Save the workbook in tab delimited format | |
wb->Save(outReadWriteTabDelimited, SaveFormat_TabDelimited); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of input excel file | |
StringPtr srcReadWriteXLSB = dirPath->StringAppend(new String("srcReadWriteXLSB.xlsb")); | |
//Path of output excel file | |
StringPtr outReadWriteXLSB = outPath->StringAppend(new String("outReadWriteXLSB.xlsb")); | |
//Read source xlsb file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(srcReadWriteXLSB); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Access cell A1 | |
intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
//Get the string value of cell A1 | |
StringPtr strVal = cell->GetStringValue(); | |
//Print the string value of cell A1 | |
StringPtr cellValue = new String("Cell Value: "); | |
Console::WriteLine(cellValue->StringAppend(strVal)); | |
//Access cell C4 | |
cell = ws->GetICells()->GetObjectByIndex(new String("C4")); | |
//Put the string value of cell A1 into C4 | |
intrusive_ptr<String> strValPtr = new String(strVal); | |
cell->PutValue(strValPtr); | |
//Save the workbook in XLSB format | |
wb->Save(outReadWriteXLSB, SaveFormat_Xlsb); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of input excel file | |
StringPtr srcReadWriteXLSM = dirPath->StringAppend(new String("srcReadWriteXLSM.xlsm")); | |
//Path of output excel file | |
StringPtr outReadWriteXLSM = outPath->StringAppend(new String("outReadWriteXLSM.xlsm")); | |
//Read source xlsm file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(srcReadWriteXLSM); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Access cell A1 | |
intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
//Get the string value of cell A1 | |
StringPtr strVal = cell->GetStringValue(); | |
//Print the string value of cell A1 | |
StringPtr cellValue = new String("Cell Value: "); | |
Console::WriteLine(cellValue->StringAppend(strVal)); | |
//Access cell C4 | |
cell = ws->GetICells()->GetObjectByIndex(new String("C4")); | |
//Put the string value of cell A1 into C4 | |
intrusive_ptr<String> strValPtr = new String(strVal); | |
cell->PutValue(strValPtr); | |
//Save the workbook in XLSM format | |
wb->Save(outReadWriteXLSM, SaveFormat_Xlsm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Load sample Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(dirPath->StringAppend(new String("sampleExcelFile.xlsx"))); | |
//Save in Excel 97-2003 format | |
workbook->Save(outPath->StringAppend(new String("outputSavingFiletoSomeLocationExcel97-2003.xls"))); | |
//OR | |
workbook->Save(outPath->StringAppend(new String("outputSavingFiletoSomeLocationOrExcel97-2003.xls")), SaveFormat_Excel97To2003); | |
//Save in Excel2007 xlsx format | |
workbook->Save(outPath->StringAppend(new String("outputSavingFiletoSomeLocationXlsx.xlsx")), SaveFormat_Xlsx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Load sample Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(dirPath->StringAppend(new String("sampleExcelFile.xlsx"))); | |
//Create FileStream object | |
intrusive_ptr<FileStream> stream = new FileStream(outPath->StringAppend(new String("outputSavingFiletoStream.xlsx")), FileMode_CreateNew); | |
//Save the Workbook to Stream | |
workbook->Save(stream, SaveFormat_Xlsx); | |
stream->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of output excel file | |
StringPtr outputCreatePivotTable = outPath->StringAppend(new String("outputCreatePivotTable.xlsx")); | |
//Load the sample excel file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Add source data for pivot table | |
intrusive_ptr<String> str = new String("Fruit"); | |
ws->GetICells()->GetObjectByIndex(new String("A1"))->PutValue(str); | |
str = new String("Quantity"); | |
ws->GetICells()->GetObjectByIndex(new String("B1"))->PutValue(str); | |
str = new String("Price"); | |
ws->GetICells()->GetObjectByIndex(new String("C1"))->PutValue(str); | |
str = new String("Apple"); | |
ws->GetICells()->GetObjectByIndex(new String("A2"))->PutValue(str); | |
str = new String("Orange"); | |
ws->GetICells()->GetObjectByIndex(new String("A3"))->PutValue(str); | |
ws->GetICells()->GetObjectByIndex(new String("B2"))->PutValue(3); | |
ws->GetICells()->GetObjectByIndex(new String("B3"))->PutValue(4); | |
ws->GetICells()->GetObjectByIndex(new String("C2"))->PutValue(2); | |
ws->GetICells()->GetObjectByIndex(new String("C3"))->PutValue(1); | |
//Add pivot table | |
int idx = ws->GetIPivotTables()->Add(new String("A1:C3"), new String("E5"), new String("MyPivotTable")); | |
//Access created pivot table | |
intrusive_ptr<IPivotTable> pt = ws->GetIPivotTables()->GetObjectByIndex(idx); | |
//Manipulate pivot table rows, columns and data fields | |
pt->AddFieldToArea(PivotFieldType_Row, pt->GetIBaseFields()->GetObjectByIndex(0)); | |
pt->AddFieldToArea(PivotFieldType_Data, pt->GetIBaseFields()->GetObjectByIndex(1)); | |
pt->AddFieldToArea(PivotFieldType_Data, pt->GetIBaseFields()->GetObjectByIndex(2)); | |
pt->AddFieldToArea(PivotFieldType_Column, pt->GetIDataField()); | |
//Set pivot table style | |
pt->SetPivotTableStyleType(PivotTableStyleType_PivotTableStyleMedium9); | |
//Save the output excel file | |
wb->Save(outputCreatePivotTable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\PivotTables\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of input excel file | |
StringPtr sampleManipulatePivotTable = dirPath->StringAppend(new String("sampleManipulatePivotTable.xlsx")); | |
//Path of output excel file | |
StringPtr outputManipulatePivotTable = outPath->StringAppend(new String("outputManipulatePivotTable.xlsx")); | |
//Load the sample excel file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleManipulatePivotTable); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Change value of cell B3 which is inside the source data of pivot table | |
intrusive_ptr<String> str = new String("Cup"); | |
ws->GetICells()->GetObjectByIndex(new String("B3"))->PutValue(str); | |
//Get the value of cell H8 before refreshing pivot table | |
intrusive_ptr<String> val = ws->GetICells()->GetObjectByIndex(new String("H8"))->GetStringValue(); | |
StringPtr str1 = new String(L"Before refreshing Pivot Table value of cell H8: "); | |
Console::WriteLine(str1->StringAppend(val)); | |
//Access pivot table, refresh and calculate it | |
intrusive_ptr<IPivotTable> pt = ws->GetIPivotTables()->GetObjectByIndex(0); | |
pt->RefreshData(); | |
pt->CalculateData(); | |
//Get the value of cell H8 after refreshing pivot table | |
val = ws->GetICells()->GetObjectByIndex(new String("H8"))->GetStringValue(); | |
StringPtr str2 = new String(L"After refreshing Pivot Table value of cell H8: "); | |
Console::WriteLine(str2->StringAppend(val)); | |
//Save the output excel file | |
wb->Save(outputManipulatePivotTable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleRowsAndColumns = dirPath->StringAppend(new String("sampleRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputRowsAndColumns = outPath->StringAppend(new String("outputRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Setting the height of all rows in the worksheet to 25 | |
worksheet->GetICells()->SetStandardHeight(25); | |
//Save the Excel file. | |
workbook->Save(outputRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleRowsAndColumns = dirPath->StringAppend(new String("sampleRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputRowsAndColumns = outPath->StringAppend(new String("outputRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Setting the height of the second row to 35 | |
worksheet->GetICells()->SetRowHeight(1, 35); | |
//Save the Excel file. | |
workbook->Save(outputRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleRowsAndColumns = dirPath->StringAppend(new String("sampleRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputRowsAndColumns = outPath->StringAppend(new String("outputRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Setting the width of all columns in the worksheet to 20.5 | |
worksheet->GetICells()->SetStandardWidth(20.5); | |
//Save the Excel file. | |
workbook->Save(outputRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleRowsAndColumns = dirPath->StringAppend(new String("sampleRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputRowsAndColumns = outPath->StringAppend(new String("outputRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Setting the width of the second column to 56.5 | |
worksheet->GetICells()->SetColumnWidth(1, 56.5); | |
//Save the Excel file. | |
workbook->Save(outputRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleCopyingRowsAndColumns = dirPath->StringAppend(new String("sampleCopyingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputCopyingRowsAndColumns = outPath->StringAppend(new String("outputCopyingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleCopyingRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Copy the third column to eighth column | |
worksheet->GetICells()->CopyColumn(worksheet->GetICells(), 2, 7); | |
//Save the Excel file. | |
workbook->Save(outputCopyingRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleCopyingRowsAndColumns = dirPath->StringAppend(new String("sampleCopyingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputCopyingRowsAndColumns = outPath->StringAppend(new String("outputCopyingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleCopyingRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Copy the second row with data, formattings, images and drawing objects to the 16th row in the worksheet. | |
worksheet->GetICells()->CopyRow(worksheet->GetICells(), 1, 15); | |
//Save the Excel file. | |
workbook->Save(outputCopyingRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleGroupingUngroupingRowsAndColumns = dirPath->StringAppend(new String("sampleGroupingUngroupingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputGroupingUngroupingRowsAndColumns = outPath->StringAppend(new String("outputGroupingUngroupingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleGroupingUngroupingRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Grouping first seven rows and first four columns | |
worksheet->GetICells()->GroupRows(0, 6, true); | |
worksheet->GetICells()->GroupColumns(0, 3, true); | |
//Save the Excel file. | |
workbook->Save(outputGroupingUngroupingRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleGroupingUngroupingRowsAndColumns = dirPath->StringAppend(new String("sampleGroupingUngroupingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputGroupingUngroupingRowsAndColumns = outPath->StringAppend(new String("outputGroupingUngroupingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleGroupingUngroupingRowsAndColumns); | |
//Accessing the second worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(1); | |
//UnGroup first seven rows and first four columns | |
worksheet->GetICells()->UngroupRows(0, 6); | |
worksheet->GetICells()->UngroupColumns(0, 3); | |
//Save the Excel file. | |
workbook->Save(outputGroupingUngroupingRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleDeleteColumn = dirPath->StringAppend(new String("sampleInsertingDeletingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputDeleteColumn = outPath->StringAppend(new String("outputInsertingDeletingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleDeleteColumn); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Deleting a column from the worksheet at 2nd position | |
worksheet->GetICells()->DeleteColumn(4); | |
//Save the Excel file. | |
workbook->Save(outputDeleteColumn); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleInsertingDeletingRowsAndColumns = dirPath->StringAppend(new String("sampleInsertingDeletingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputInsertingDeletingRowsAndColumns = outPath->StringAppend(new String("outputInsertingDeletingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleInsertingDeletingRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Deleting 10 rows from the worksheet starting from 3rd row | |
worksheet->GetICells()->DeleteRows(2, 10); | |
//Save the Excel file. | |
workbook->Save(outputInsertingDeletingRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleInsertingDeletingRowsAndColumns = dirPath->StringAppend(new String("sampleInsertingDeletingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputInsertingDeletingRowsAndColumns = outPath->StringAppend(new String("outputInsertingDeletingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleInsertingDeletingRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Inserting a column into the worksheet at 2nd position | |
worksheet->GetICells()->InsertColumn(1); | |
//Save the Excel file. | |
workbook->Save(outputInsertingDeletingRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleInsertingDeletingRowsAndColumns = dirPath->StringAppend(new String("sampleInsertingDeletingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputInsertingDeletingRowsAndColumns = outPath->StringAppend(new String("outputInsertingDeletingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleInsertingDeletingRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Inserting 10 rows into the worksheet starting from 3rd row | |
worksheet->GetICells()->InsertRows(2, 10); | |
//Save the Excel file. | |
workbook->Save(outputInsertingDeletingRowsAndColumns); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleInsertingDeletingRowsAndColumns = dirPath->StringAppend(new String("sampleInsertingDeletingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputInsertingDeletingRowsAndColumns = outPath->StringAppend(new String("outputInsertingDeletingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleInsertingDeletingRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Inserting a row into the worksheet at 3rd position | |
worksheet->GetICells()->InsertRow(2); | |
//Save the Excel file. | |
workbook->Save(outputInsertingDeletingRowsAndColumns); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of output excel file | |
StringPtr outputApplyCustomThemeColorsOfWorkbookUsingArrayOfColors = outPath->StringAppend(new String("outputApplyCustomThemeColorsOfWorkbookUsingArrayOfColors.xlsx")); | |
//Create a workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Create array of custom theme colors | |
intrusive_ptr<Array1D<Systems::Drawing::Color*>> clrs = new Array1D<Systems::Drawing::Color*>(12); | |
//Background1 | |
clrs->SetValue(Systems::Drawing::Color::GetRed(), 0); | |
//Text1 | |
clrs->SetValue(Systems::Drawing::Color::GetRed(), 1); | |
//Background2 | |
clrs->SetValue(Systems::Drawing::Color::GetRed(), 2); | |
//Text2 | |
clrs->SetValue(Systems::Drawing::Color::GetRed(), 3); | |
//Accent1 | |
clrs->SetValue(Systems::Drawing::Color::GetRed(), 4); | |
//Accent2 | |
clrs->SetValue(Systems::Drawing::Color::GetGreen(), 5); | |
//Accent3 | |
clrs->SetValue(Systems::Drawing::Color::GetGreen(), 6); | |
//Accent4 | |
clrs->SetValue(Systems::Drawing::Color::GetGreen(), 7); | |
//Accent5 | |
clrs->SetValue(Systems::Drawing::Color::GetGreen(), 8); | |
//Accent6 | |
clrs->SetValue(Systems::Drawing::Color::GetBlue(), 9); | |
//Hyperlink | |
clrs->SetValue(Systems::Drawing::Color::GetBlue(), 10); | |
//Followed Hyperlink | |
clrs->SetValue(Systems::Drawing::Color::GetBlue(), 11); | |
//Apply custom theme colors on workbook | |
wb->CustomTheme(new String("AnyTheme"), clrs); | |
//Save the workbook | |
wb->Save(outputApplyCustomThemeColorsOfWorkbookUsingArrayOfColors); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\TechnicalArticles\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Paths of source and output excel files | |
StringPtr damaskPath = dirPath->StringAppend(new String("DamaskTheme.xlsx")); | |
StringPtr sampleCopyThemeFromOneWorkbookToAnother = dirPath->StringAppend(new String("sampleCopyThemeFromOneWorkbookToAnother.xlsx")); | |
StringPtr outputCopyThemeFromOneWorkbookToAnother = outPath->StringAppend(new String("outputCopyThemeFromOneWorkbookToAnother.xlsx")); | |
//Read excel file that has Damask theme applied on it | |
intrusive_ptr<IWorkbook> damask = Factory::CreateIWorkbook(damaskPath); | |
//Read your sample excel file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleCopyThemeFromOneWorkbookToAnother); | |
//Copy theme from source file | |
wb->CopyTheme(damask); | |
//Save the workbook in xlsx format | |
wb->Save(outputCopyThemeFromOneWorkbookToAnother, SaveFormat_Xlsx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\TechnicalArticles\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of input excel file | |
StringPtr sampleCreateAndManipulateExcelTable = dirPath->StringAppend(new String("sampleCreateAndManipulateExcelTable.xlsx")); | |
//Path of output excel file | |
StringPtr outputCreateAndManipulateExcelTable = outPath->StringAppend(new String("outputCreateAndManipulateExcelTable.xlsx")); | |
//Load the sample excel file | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleCreateAndManipulateExcelTable); | |
//Access first worksheet | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Add table i.e. list object | |
int idx = ws->GetIListObjects()->Add(new String("A1"), new String("H10"), true); | |
//Access the newly added list object | |
intrusive_ptr<IListObject> lo = ws->GetIListObjects()->GetObjectByIndex(idx); | |
//Use its display methods | |
lo->SetShowHeaderRow(true); | |
lo->SetShowTableStyleColumnStripes(true); | |
lo->SetShowTotals(true); | |
//Set its style | |
lo->SetTableStyleType(TableStyleType_TableStyleLight12); | |
//Set total functions of 3rd, 4th and 5th columns | |
lo->GetIListColumns()->GetObjectByIndex(2)->SetTotalsCalculation(TotalsCalculation_Min); | |
lo->GetIListColumns()->GetObjectByIndex(3)->SetTotalsCalculation(TotalsCalculation_Max); | |
lo->GetIListColumns()->GetObjectByIndex(4)->SetTotalsCalculation(TotalsCalculation_Count); | |
//Save the output excel file | |
wb->Save(outputCreateAndManipulateExcelTable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Path of output excel file | |
StringPtr outputGroupRowsAndColumnsOfWorksheet = outPath->StringAppend(new String("outputGroupRowsAndColumnsOfWorksheet.xlsx")); | |
//Create an empty workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Add worksheet for grouping rows | |
intrusive_ptr<IWorksheet> grpRows = wb->GetIWorksheets()->GetObjectByIndex(0); | |
grpRows->SetName(new String("GroupRows")); | |
//Add worksheet for grouping columns | |
int idx = wb->GetIWorksheets()->Add(); | |
intrusive_ptr<IWorksheet> grpCols = wb->GetIWorksheets()->GetObjectByIndex(idx); | |
grpCols->SetName(new String("GroupColumns")); | |
//Add sample values in both worksheets | |
for (int i = 0; i<50; i++) | |
{ | |
intrusive_ptr<String> str = new String("Text"); | |
grpRows->GetICells()->GetObjectByIndex(i, 0)->PutValue(str); | |
grpCols->GetICells()->GetObjectByIndex(0, i)->PutValue(str); | |
} | |
//Grouping rows at first level | |
grpRows->GetICells()->GroupRows(0, 10); | |
grpRows->GetICells()->GroupRows(12, 22); | |
grpRows->GetICells()->GroupRows(24, 34); | |
//Grouping rows at second level | |
grpRows->GetICells()->GroupRows(2, 8); | |
grpRows->GetICells()->GroupRows(14, 20); | |
grpRows->GetICells()->GroupRows(28, 30); | |
//Grouping rows at third level | |
grpRows->GetICells()->GroupRows(5, 7); | |
//Grouping columns at first level | |
grpCols->GetICells()->GroupColumns(0, 10); | |
grpCols->GetICells()->GroupColumns(12, 22); | |
grpCols->GetICells()->GroupColumns(24, 34); | |
//Grouping columns at second level | |
grpCols->GetICells()->GroupColumns(2, 8); | |
grpCols->GetICells()->GroupColumns(14, 20); | |
grpCols->GetICells()->GroupColumns(28, 30); | |
//Grouping columns at third level | |
grpCols->GetICells()->GroupColumns(5, 7); | |
//Save the output excel file | |
wb->Save(outputGroupRowsAndColumnsOfWorksheet); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleCopyingAndMovingWorksheets = srcDir->StringAppend(new String("sampleCopyingAndMovingWorksheets.xlsx")); | |
//Path of output excel file | |
StringPtr outputCopyingAndMovingWorksheets = outDir->StringAppend(new String("outputCopyingAndMovingWorksheets.xlsx")); | |
//Create workbook | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleCopyingAndMovingWorksheets); | |
//Create worksheets object with reference to the sheets of the workbook. | |
intrusive_ptr<IWorksheetCollection> sheets = workbook->GetIWorksheets(); | |
//Copy data to a new sheet from an existing sheet within the workbook. | |
sheets->AddCopy(new String("Test1")); | |
//Save the Excel file. | |
workbook->Save(outputCopyingAndMovingWorksheets); | |
StringPtr msg = new String("Worksheet copied successfully with in a workbook!"); | |
Console::WriteLine(msg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleCopyingAndMovingWorksheets = srcDir->StringAppend(new String("sampleCopyingAndMovingWorksheets.xlsx")); | |
//Path of output excel file | |
StringPtr outputCopyingAndMovingWorksheets = outDir->StringAppend(new String("outputCopyingAndMovingWorksheets.xlsx")); | |
//Create workbook | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleCopyingAndMovingWorksheets); | |
//Create worksheets object with reference to the sheets of the workbook. | |
intrusive_ptr<IWorksheetCollection> sheets = workbook->GetIWorksheets(); | |
//Access the first sheet | |
intrusive_ptr<IWorksheet> sheet = sheets->GetObjectByIndex(0); | |
//Move the first sheet to the third position in the workbook. | |
sheet->MoveTo(2); | |
//Save the Excel file. | |
workbook->Save(outputCopyingAndMovingWorksheets); | |
StringPtr msg = new String("Worksheet moved successfully with in a workbook!"); | |
Console::WriteLine(msg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleManageWorksheets = srcDir->StringAppend(new String("sampleManageWorksheets.xlsx")); | |
//Load the sample Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleManageWorksheets); | |
//Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Access the cell by its name. | |
intrusive_ptr<ICell> cell = worksheet->GetICells()->GetObjectByIndex(new String("F7")); | |
//Print the value of cell F7 | |
StringPtr val = cell->GetStringValue(); | |
//Print the value on console. | |
Console::Write(new String("Value of cell F7: ")); | |
Console::WriteLine(val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of output excel file | |
StringPtr outputManageWorksheets = outDir->StringAppend(new String("outputManageWorksheets.xlsx")); | |
//Create workbook | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(); | |
// Adding a new worksheet to the Workbook object | |
int i = workbook->GetIWorksheets()->Add(); | |
// Obtaining the reference of the newly added worksheet by passing its sheet index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(i); | |
// Setting the name of the newly added worksheet | |
worksheet->SetName(new String("My Worksheet")); | |
// Save the Excel file. | |
workbook->Save(outputManageWorksheets); | |
StringPtr msg = new String("New worksheet added successfully with in a workbook!"); | |
Console::WriteLine(msg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleManageWorksheets = srcDir->StringAppend(new String("sampleManageWorksheets.xlsx")); | |
//Path of output excel file | |
StringPtr outputManageWorksheets = outDir->StringAppend(new String("outputManageWorksheets.xlsx")); | |
//Load the sample Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleManageWorksheets); | |
//Removing a worksheet using its sheet index | |
workbook->GetIWorksheets()->RemoveAt(0); | |
//Save the Excel file. | |
workbook->Save(outputManageWorksheets); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of output excel file | |
StringPtr outputPageBreaks = outDir->StringAppend(new String("outputManagingPageBreaks.xlsx")); | |
//Instantiating a Workbook object | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(); | |
//Add a page break at cell J20 | |
workbook->GetIWorksheets()->GetObjectByIndex(0)->AddPageBreaks(new String("J20")); | |
//Save the Excel file. | |
workbook->Save(outputPageBreaks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleWorksheetViews = srcDir->StringAppend(new String("sampleWorksheetViews.xlsx")); | |
//Path of input excel file | |
StringPtr outputWorksheetViews = outDir->StringAppend(new String("outputWorksheetViews.xlsx")); | |
//Instantiate a workbook object | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleWorksheetViews); | |
//Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Displaying the worksheet in page break preview | |
worksheet->SetIsPageBreakPreview(true); | |
//Save the Excel file | |
workbook->Save(outputWorksheetViews); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleWorksheetViews = srcDir->StringAppend(new String("sampleWorksheetViews.xlsx")); | |
//Path of input excel file | |
StringPtr outputWorksheetViews = outDir->StringAppend(new String("outputWorksheetViews.xlsx")); | |
//Instantiating a Workbook object and opening the Excel file through the file stream | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleWorksheetViews); | |
//Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Applying freeze panes settings | |
worksheet->FreezePanes(3, 2, 3, 2); | |
//Saving the modified Excel file | |
workbook->Save(outputWorksheetViews); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleWorksheetViews = srcDir->StringAppend(new String("sampleWorksheetViews.xlsx")); | |
//Path of input excel file | |
StringPtr outputWorksheetViews = outDir->StringAppend(new String("outputWorksheetViews.xlsx")); | |
//Instantiating a Workbook object | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleWorksheetViews); | |
//Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Set the active cell | |
worksheet->SetActiveCell(new String("A20")); | |
// Split the worksheet window | |
worksheet->RemoveSplit(); | |
//Saving the modified Excel file | |
workbook->Save(outputWorksheetViews); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleWorksheetViews = srcDir->StringAppend(new String("sampleWorksheetViews.xlsx")); | |
//Path of input excel file | |
StringPtr outputWorksheetViews = outDir->StringAppend(new String("outputWorksheetViews.xlsx")); | |
//Instantiating a Workbook object | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleWorksheetViews); | |
//Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Set the active cell | |
worksheet->SetActiveCell(new String("A20")); | |
//Split the worksheet window | |
worksheet->Split(); | |
//Saving the modified Excel file | |
workbook->Save(outputWorksheetViews); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
//Output directory path | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
//Path of input excel file | |
StringPtr sampleWorksheetViews = srcDir->StringAppend(new String("sampleWorksheetViews.xlsx")); | |
//Path of input excel file | |
StringPtr outputWorksheetViews = outDir->StringAppend(new String("outputWorksheetViews.xlsx")); | |
//Instantiate a workbook object | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleWorksheetViews); | |
//Accessing a worksheet using its index | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Setting the zoom factor of the worksheet to 75 | |
worksheet->SetZoom(75); | |
// Saving the modified Excel file | |
workbook->Save(outputWorksheetViews); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Output directory path. | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of output Pdf file. | |
StringPtr outputConvertExcelWorkbookToPDF = outDir->StringAppend(new String("outputConvertExcelWorkbookToPDF_PdfCompliance_PdfA1b.pdf")); | |
// Create an empty workbook. | |
intrusive_ptr<Aspose::Cells::IWorkbook> workbook = Factory::CreateIWorkbook(); | |
// Access first worksheet. | |
intrusive_ptr<Aspose::Cells::IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Access cell A1. | |
intrusive_ptr<Aspose::Cells::ICell> cell = worksheet->GetICells()->GetObjectByIndex(new String("A1")); | |
// Add some text in cell. | |
cell->PutValue((StringPtr)new String("Testing PDF/A")); | |
// Create pdf save options object. | |
intrusive_ptr<Aspose::Cells::IPdfSaveOptions> pdfSaveOptions = Factory::CreateIPdfSaveOptions(); | |
// Set the compliance to PDF/A-1b. | |
pdfSaveOptions->SetCompliance(Aspose::Cells::Rendering::PdfCompliance_PdfA1b); | |
// Save the Excel Document in PDF format | |
workbook->Save(outputConvertExcelWorkbookToPDF, pdfSaveOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Source directory path. | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
// Output directory path. | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of input Excel file | |
StringPtr sampleConvertExcelWorkbookToPDF = srcDir->StringAppend(new String("sampleConvertExcelWorkbookToPDF.xlsx")); | |
// Path of output Pdf file | |
StringPtr outputConvertExcelWorkbookToPDF = outDir->StringAppend(new String("outputConvertExcelWorkbookToPDF_DirectConversion.pdf")); | |
// Load the sample Excel file. | |
intrusive_ptr<Aspose::Cells::IWorkbook> workbook = Factory::CreateIWorkbook(sampleConvertExcelWorkbookToPDF); | |
// Save the Excel Document in PDF format | |
workbook->Save(outputConvertExcelWorkbookToPDF, SaveFormat_Pdf); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Output directory path. | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of output Pdf file. | |
StringPtr outputConvertExcelWorkbookToPDF = outDir->StringAppend(new String("outputConvertExcelWorkbookToPDF_PDFCreationTime.pdf")); | |
// Create an empty workbook. | |
intrusive_ptr<Aspose::Cells::IWorkbook> workbook = Factory::CreateIWorkbook(); | |
// Access first worksheet. | |
intrusive_ptr<Aspose::Cells::IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Access cell A1. | |
intrusive_ptr<Aspose::Cells::ICell> cell = worksheet->GetICells()->GetObjectByIndex(new String("A1")); | |
// Add some text in cell. | |
cell->PutValue((StringPtr)new String("PDF Creation Time is 25-May-2017.")); | |
// Create pdf save options object. | |
intrusive_ptr<Aspose::Cells::IPdfSaveOptions> pdfSaveOptions = Factory::CreateIPdfSaveOptions(); | |
// Set the created time for the PDF i.e. 25-May-2017 | |
pdfSaveOptions->SetCreatedTime(new Aspose::Cells::Systems::DateTime(2017, 5, 25)); | |
// Save the Excel Document in PDF format | |
workbook->Save(outputConvertExcelWorkbookToPDF, pdfSaveOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Source directory path. | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
// Output directory path. | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of input Excel file. | |
StringPtr sampleConvertingWorksheetToDifferentImageFormats = srcDir->StringAppend(new String("sampleConvertingWorksheetToDifferentImageFormats.xlsx")); | |
// Create an empty workbook. | |
intrusive_ptr<Aspose::Cells::IWorkbook> workbook = Factory::CreateIWorkbook(sampleConvertingWorksheetToDifferentImageFormats); | |
// Access first worksheet. | |
intrusive_ptr<Aspose::Cells::IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Create image or print options object. | |
intrusive_ptr<Aspose::Cells::Rendering::IImageOrPrintOptions> imgOptions = Factory::CreateIImageOrPrintOptions(); | |
// Specify the image format. | |
imgOptions->SetImageFormat(Aspose::Cells::Systems::Drawing::Imaging::ImageFormat::GetPng()); | |
// Specify horizontal and vertical resolution | |
imgOptions->SetHorizontalResolution(200); | |
imgOptions->SetVerticalResolution(200); | |
// Render the sheet with respect to specified image or print options. | |
intrusive_ptr<Aspose::Cells::Rendering::ISheetRender> sr = Factory::CreateISheetRender(worksheet, imgOptions); | |
// Get page count. | |
Aspose::Cells::Systems::Int32 pageCount = sr->GetPageCount(); | |
// Create string builder object for string concatenations. | |
intrusive_ptr<Aspose::Cells::Systems::Text::StringBuilder> sb = new Aspose::Cells::Systems::Text::StringBuilder(); | |
// Render each page to png image one by one. | |
for (int i = 0; i < pageCount; i++) | |
{ | |
// Clear string builder and create output image path with string concatenations. | |
sb->Clear(); | |
sb->Append(outDir); | |
sb->Append((StringPtr)new String("outputConvertingWorksheetToImagePNG_")); | |
sb->Append(i); | |
sb->Append((StringPtr)new String(".png")); | |
// Get the output image path. | |
StringPtr outputPNG = sb->ToString(); | |
// Convert worksheet to png image. | |
sr->ToImage(i, outputPNG); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Source directory path. | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
// Output directory path. | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of input Excel file. | |
StringPtr sampleConvertingWorksheetToDifferentImageFormats = srcDir->StringAppend(new String("sampleConvertingWorksheetToDifferentImageFormats.xlsx")); | |
// Create an empty workbook. | |
intrusive_ptr<Aspose::Cells::IWorkbook> workbook = Factory::CreateIWorkbook(sampleConvertingWorksheetToDifferentImageFormats); | |
// Access first worksheet. | |
intrusive_ptr<Aspose::Cells::IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Create image or print options object. | |
intrusive_ptr<Aspose::Cells::Rendering::IImageOrPrintOptions> imgOptions = Factory::CreateIImageOrPrintOptions(); | |
// Specify horizontal and vertical resolution | |
imgOptions->SetHorizontalResolution(200); | |
imgOptions->SetVerticalResolution(200); | |
// Specify the save format. | |
imgOptions->SetSaveFormat(Aspose::Cells::SaveFormat::SaveFormat_SVG); | |
// Render the sheet with respect to specified image or print options. | |
intrusive_ptr<Aspose::Cells::Rendering::ISheetRender> sr = Factory::CreateISheetRender(worksheet, imgOptions); | |
// Get page count. | |
Aspose::Cells::Systems::Int32 pageCount = sr->GetPageCount(); | |
// Create string builder object for string concatenations. | |
intrusive_ptr<Aspose::Cells::Systems::Text::StringBuilder> sb = new Aspose::Cells::Systems::Text::StringBuilder(); | |
// Render each page to png image one by one. | |
for (int i = 0; i < pageCount; i++) | |
{ | |
// Clear string builder and create output image path with string concatenations. | |
sb->Clear(); | |
sb->Append(outDir); | |
sb->Append((StringPtr)new String("outputConvertingWorksheetToImageSVG_")); | |
sb->Append(i); | |
sb->Append((StringPtr)new String(".svg")); | |
// Get the output image path. | |
StringPtr outputSVG = sb->ToString(); | |
// Convert worksheet to tiff image. | |
sr->ToImage(i, outputSVG); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
// Source directory path. | |
StringPtr srcDir = new String("..\\Data\\01_SourceDirectory\\"); | |
// Output directory path. | |
StringPtr outDir = new String("..\\Data\\02_OutputDirectory\\"); | |
// Path of input Excel file. | |
StringPtr sampleConvertingWorksheetToDifferentImageFormats = srcDir->StringAppend(new String("sampleConvertingWorksheetToDifferentImageFormats.xlsx")); | |
// Create an empty workbook. | |
intrusive_ptr<Aspose::Cells::IWorkbook> workbook = Factory::CreateIWorkbook(sampleConvertingWorksheetToDifferentImageFormats); | |
// Access first worksheet. | |
intrusive_ptr<Aspose::Cells::IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Create image or print options object. | |
intrusive_ptr<Aspose::Cells::Rendering::IImageOrPrintOptions> imgOptions = Factory::CreateIImageOrPrintOptions(); | |
// Specify the image format. | |
imgOptions->SetImageFormat(Aspose::Cells::Systems::Drawing::Imaging::ImageFormat::GetTiff()); | |
// Specify horizontal and vertical resolution | |
imgOptions->SetHorizontalResolution(200); | |
imgOptions->SetVerticalResolution(200); | |
// Render the sheet with respect to specified image or print options. | |
intrusive_ptr<Aspose::Cells::Rendering::ISheetRender> sr = Factory::CreateISheetRender(worksheet, imgOptions); | |
// Get the output image path. | |
StringPtr outputTiff = outDir->Append((StringPtr)new String("outputConvertingWorksheetToImageTiff.tiff")); | |
// Convert worksheet to tiff image. | |
sr->ToTiff(outputTiff); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment