Skip to content

Instantly share code, notes, and snippets.

@fileformat-cells-gists
Created March 28, 2024 07:17
Show Gist options
  • Save fileformat-cells-gists/0779e0b4e8da19cc73e11ed080fc2f1d to your computer and use it in GitHub Desktop.
Save fileformat-cells-gists/0779e0b4e8da19cc73e11ed080fc2f1d to your computer and use it in GitHub Desktop.
This C# example showcases how to open an existing MS excel workbook and insert text into a specified cell using the FileFormat.Cells library.
using FileFormat.Cells
string filePath = "Z:\\Downloads\\testFile1.xlsx";
// Load the workbook from the specified file path
using (Workbook wb = new Workbook(filePath))
{
// Access the first worksheet in the workbook
Worksheet firstSheet = wb.Worksheets[0];
// Define the cellReference
string cellReference = "B10";
Cell cell = firstSheet.Cells[cellReference];
// Insert the actual value to the cell.
cell.PutValue("randomValue");
wb.Save(filePath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment