Skip to content

Instantly share code, notes, and snippets.

View fileformat-cells-gists's full-sized avatar

fileformat-cells-gists

View GitHub Profile
@fileformat-cells-gists
fileformat-cells-gists / FreezePaneExample.cs
Created October 21, 2024 06:47
Example of using FreezePane to lock rows and columns in a worksheet and retrieve the frozen row and column indexes.
using FileFormat.Cells
public class FreezePaneExample
{
public static void Main(string[] args)
{
string filePath = "your-file-path.xlsx"; // Replace with your file path
using (Workbook wb = new Workbook(filePath))
{
@fileformat-cells-gists
fileformat-cells-gists / get-hidden-sheets.cs
Created August 28, 2024 10:34
This C# example showcases how to get List of Hidden Sheets a MS Excel Spreadsheet in C# using FileFormat.Cells SDK
using FileFormat.Cells
string filePath = "Z:\\Downloads\\hidden_sheets.xlsx";
using (Workbook wb = new Workbook(filePath))
{
List<Tuple<string, string>> hiddenSheets = wb.GetHiddenSheets();
foreach (var sheet in hiddenSheets)
{
@fileformat-cells-gists
fileformat-cells-gists / get-column-heading.cs
Last active August 28, 2024 10:15
This C# example showcases how to get Column Heading from a MS Excel worksheet in C# using FileFormat.Cells SDK
using FileFormat.Cells
string filePath = "Z:\\Downloads\\testFile1.xlsx";
// Load the workbook from the specified file path
using (Workbook wb = new Workbook(filePath))
{
Worksheet firstSheet = wb.Worksheet[0];
string columnHeading = firstSheet.GetColumnHeading("B");
@fileformat-cells-gists
fileformat-cells-gists / rename-excel-sheet-in-cshap.cs
Created August 6, 2024 05:19
This C# example showcases how to rename a MS Excel worksheet in C# using Openize.Cells SDK
using FileFormat.Cells
string filePath = "Z:\\Downloads\\testFile1.xlsx";
string existingSheetName = "TestSheet";
string newSheetName = "RenameSheetName";
// Load the workbook from the specified file path
using (Workbook wb = new Workbook(filePath))
{
wb.RenameSheet(existingSheetName, newSheetName);
@fileformat-cells-gists
fileformat-cells-gists / set-visibility-within-worksheet.cs
Created August 6, 2024 05:18
This C# example showcases how to set visibility within a MS Excel worksheet in C# using Openize.Cells
using FileFormat.Cells
string filePath = "Z:\\Downloads\\testFile1.xlsx";
string sheetName = "TestSheet";
// Load the workbook from the specified file path
using (Workbook wb = new Workbook(filePath))
{
wb.SetSheetVisibility(sheetName, SheetVisibility.Hidden);
wb.Save(filePath);
@fileformat-cells-gists
fileformat-cells-gists / add-comments-into-worksheet.cs
Created April 19, 2024 11:05
This C# example illustrates how to add comments in Google Sheets / Excel Spread sheet using the FileFormat.Cells library.
// Define the directory where files are stored
string outputDirectory = "Z:\\Downloads\\";
// Specify the path to the Excel file
string filePath = "Z:\\Downloads\\testFile1.xlsx";
// Open the workbook located at the specified file path
using (Workbook wb = new Workbook(filePath))
{
// Access the first worksheet in the workbook
@fileformat-cells-gists
fileformat-cells-gists / open-existing-workbook.cs
Created March 28, 2024 07:17
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];
@fileformat-cells-gists
fileformat-cells-gists / insert-columns-into-worksheet.cs
Created February 14, 2024 13:25
This C# example illustrates how to insert a specific number of columns into an Excel worksheet using the FileFormat.Cells library. The process involves loading the workbook, selecting the target worksheet, inserting the desired number of columns from a specified start column, and saving the workbook to apply the changes. It's a useful guide for …
using FileFormat.Cells;
using (Workbook wb = new Workbook(filePath))
{
string startColumn = "B";
int numberOfColumns = 3;
Worksheet firstSheet = wb.Worksheets[0];
@fileformat-cells-gists
fileformat-cells-gists / insert-rows-into-worksheet.cs
Created February 14, 2024 11:43
This C# example showcases how to programmatically insert rows into an Excel worksheet at a specified row index using the FileFormat.Cells library.
using FileFormat.Cells;
// 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 starting row index and the number of rows to insert
uint startRowIndex = 5;
@fileformat-cells-gists
fileformat-cells-gists / set-range-value-in-worksheet.cs
Created February 14, 2024 10:52
This C# example demonstrates how to select a specific range within an Excel worksheet and set the same value to all cells within that range using the FileFormat.Cells library.
using FileFormat.Cells;
// 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];
// Select a range within the worksheet
var range = firstSheet.GetRange("A1", "B10");
Console.WriteLine($"Column count: {range.ColumnCount}");