Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created December 6, 2023 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/8536c2d2561d6a5d4e97ee77729e16f4 to your computer and use it in GitHub Desktop.
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
/*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")));
// 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);
// 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");
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...");
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);
# 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