Skip to main content

Spreadsheetgear Example - !!install!!

Inside this example, you make an brand-new workbook and obtain an pointer toward the initial tab. You next assign this content in cellular A1 to “Hello, World!” plus format the box via making that font bold plus increasing the size = 14. Finally, they write that spreadsheet into one document named “example.xlsx”.

SpreadsheetGear Example: Reading plus Writing Excel Files Inside the example, we’ll load one existing Excel file and export that content to one fresh file. spreadsheetgear example

using SpreadsheetGear; type Program static void Main(string[] args) // Create a new workbook IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(); // Get the first worksheet IWorksheet worksheet = workbook.Worksheets[0]; // Set the values of some cells worksheet.Cells["A1"].Value = 10; worksheet.Cells["B1"].Value = 20; // Set a formula for a cell worksheet.Cells["C1"].Formula = "=A1+B1"; // Calculate the formula worksheet.Calculate(); // Get the result of the formula object result = worksheet.Cells["C1"].Value; // Save the workbook to a file workbook.SaveTo("example.xlsx"); Inside this example, you make an brand-new workbook

using SpreadsheetGear; class Program {{} static void Main(string[] args) // Open an existing workbook IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook("input.xlsx"); // Get the first worksheet IWorksheet worksheet = workbook.Worksheets[0]; // Read the values from a range of cells IRange range = worksheet.Cells["A1:B2"]; object[,] values = range.Values; // Create a new workbook IWorkbook newWorkbook = SpreadsheetGear.Factory.GetWorkbook(); IWorksheet newWorksheet = newWorkbook.Worksheets[0]; // Write the values to a new range of cells newWorksheet.Cells["A1:B2"].Values = values; // Save the new workbook to a file newWorkbook.SaveTo("output.xlsx"); } Finally, we save the new workbook to a file called “output

In this example, we open an existing workbook and read the values from a range of cells. We then create a new workbook and write the values to a new range of cells. Finally, we save the new workbook to a file called “output.xlsx”.