Read the complete article on creating Excel files in C#, Java, Python, C++, PHP, and Node.js: https://blog.aspose.com/cells/programmatically-create-excel-files/
Created
December 6, 2023 14:59
-
-
Save aspose-com-gists/8536c2d2561d6a5d4e97ee77729e16f4 to your computer and use it in GitHub Desktop.
Create Excel Files in C#, Java, Python, C++, PHP, and Node.js
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
/*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(resultPath->StringAppend(new String("workbook.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
// Instantiate a Workbook object that represents Excel file. | |
Workbook wb = new Workbook(); | |
// When you create a new workbook, a default "Sheet1" is added to the workbook. | |
Worksheet sheet = wb.Worksheets[0]; | |
// Access the "A1" cell in the sheet. | |
Cell cell = sheet.Cells["A1"]; | |
// Input the "Hello World!" text into the "A1" cell. | |
cell.PutValue("Hello World!"); | |
// Save the Excel as .xlsx file. | |
wb.Save("Excel.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
// Create a new workbook | |
Workbook workbook = new Workbook(); | |
// Add value in the cell | |
workbook.getWorksheets().get(0).getCells().get("A1").putValue("Hello World!"); | |
// Save as Excel XLSX file | |
workbook.save("Excel.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
var aspose = aspose || {}; | |
aspose.cells = require("aspose.cells"); | |
// create a new workbook | |
var workbook = new aspose.cells.Workbook(aspose.cells.FileFormatType.XLSX); | |
// add value in the cell | |
workbook.getWorksheets().get(0).getCells().get("A1").putValue("Hello World!"); | |
// save as Excel XLSX file | |
workbook.save("Excel.xlsx"); | |
console.log("done..."); |
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
require_once("http://localhost:8080/JavaBridge/java/Java.inc"); | |
require_once("aspose.cells.php"); | |
use aspose\cells; | |
// Create an object of workbook class | |
$workbook = new cells\Workbook(); | |
// Access the worksheets | |
$sheets = $workbook->getWorksheets(); | |
// Access the cells of desired worksheet | |
$cells = $sheets->get(0)->getCells(); | |
// Insert value to the cell | |
$cells->get("A1")->putValue("Hello world!"); | |
// Save the Excel file | |
$workbook->save("output.xlsx", cells\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
# Create a new XLSX workbook | |
wb = Workbook(FileFormatType.XLSX) | |
# Insert value in the cells | |
wb.getWorksheets().get(0).getCells().get("A1").putValue("Hello World!") | |
# Save workbook as .xlsx file | |
wb.save("workbook.xlsx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment