You can find detailed information at: Copy Rows and Columns in Excel using C++
Last active
September 6, 2021 11:03
-
-
Save aspose-com-gists/91953e5b36223b2b43268c46d5b32394 to your computer and use it in GitHub Desktop.
Copy Rows and Columns in Excel using 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
// Source directory path. | |
StringPtr srcDir = new String("SourceDirectory\\Excel\\"); | |
// Output directory path. | |
StringPtr outDir = new String("OutputDirectory\\"); | |
// Load the input Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(srcDir->StringAppend(new String("Sample1.xlsx"))); | |
// Get the first worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Copy Column | |
worksheet->GetICells()->CopyIColumn(worksheet->GetICells(), 0, 6); | |
// Save the Excel file | |
workbook->Save(outDir->StringAppend(new String("CopyColumn_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
// Source directory path. | |
StringPtr srcDir = new String("SourceDirectory\\Excel\\"); | |
// Output directory path. | |
StringPtr outDir = new String("OutputDirectory\\"); | |
// Load the input Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(srcDir->StringAppend(new String("Sample1.xlsx"))); | |
// Get the first worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Copy Columns | |
worksheet->GetICells()->CopyIColumns(worksheet->GetICells(), 0, 6, 3); | |
// Save the Excel file | |
workbook->Save(outDir->StringAppend(new String("CopyColumns_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
// Source directory path. | |
StringPtr srcDir = new String("SourceDirectory\\Excel\\"); | |
// Output directory path. | |
StringPtr outDir = new String("OutputDirectory\\"); | |
// Load the input Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(srcDir->StringAppend(new String("Sample1.xlsx"))); | |
// Get the first worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Copy Row | |
worksheet->GetICells()->CopyIRow(worksheet->GetICells(), 1, 15); | |
// Save the Excel file | |
workbook->Save(outDir->StringAppend(new String("CopyRow_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
// Source directory path. | |
StringPtr srcDir = new String("SourceDirectory\\Excel\\"); | |
// Output directory path. | |
StringPtr outDir = new String("OutputDirectory\\"); | |
// Load the input Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(srcDir->StringAppend(new String("Sample1.xlsx"))); | |
// Get the first worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Copy Rows | |
worksheet->GetICells()->CopyIRows(worksheet->GetICells(), 1, 15, 3); | |
// Save the Excel file | |
workbook->Save(outDir->StringAppend(new String("CopyRows_out.xlsx"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment