- Home
- Purchase
- Developer Tools
- BarCode Generator SDK
- BarCode Generator SDK for Javascript for Code 128
- BarCode Reader SDK
- PDF Generator SDK for Javascript
- PDF Extractor SDK
- PDF Renderer SDK
- PDF To HTML SDK
- PDF Viewer SDK
- Spreadsheet SDK
- Image To Video SDK
- Screen Video Capturing SDK
- SWF To Video and Images SDK
- Images Watermarking SDK
- Document SDK beta
- Misc Tools
- Desktop Utilities
- Download
- Support
- Company
- Labs
Write formula into cell in XLS Excel document using Bytescout Spreadsheet SDK
How to write a formula into a cell in the Excel spreadsheet generated by Bytescout Spreadsheet SDK
This source code sample demonstrates how to write formula into a cell in a new excel spreadsheet made with Bytescout Spreadsheet SDK for .NET
Download example source code: bytescoutxls_write_formula_into_cell.zip (2 KB)

using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.Spreadsheet;
using System.Diagnostics;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
// Create new Spreadsheet
Spreadsheet document = new Spreadsheet();
// add new worksheet
Worksheet Sheet = document.Workbook.Worksheets.Add("FormulaDemo");
// headers to indicate purpose of the column
Sheet.Cell("A1").Value = "Formula (as text)";
// set A column width
Sheet.Columns[0].Width = 250;
Sheet.Cell("B1").Value = "Formula (calculated)";
// set B column width
Sheet.Columns[1].Width = 250;
// write formula as text
Sheet.Cell("A2").Value = "7*3+2";
// write formula as formula
Sheet.Cell("B2").Value = "=7*3+2";
// save generated XLS document into new file
document.SaveAs("WritingFormulaDemo.xls");
// open generated document in Excel (if installed)
Process.Start("WritingFormulaDemo.xls");
}
}
}
Download example source code: bytescoutxls_write_formula_into_cell.zip (2 KB)
Filed in:
Spreadsheet SDK
Tutorials:









