Skip to content

Instantly share code, notes, and snippets.

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

openize-cells-gists

View GitHub Profile
@openize-cells-gists
openize-cells-gists / set-visibility-within-worksheet.cs
Created June 22, 2024 06:54
This C# example showcases how to set visibility within a MS Excel worksheet in C# using Openize.Cells
using Openize.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);
@openize-cells-gists
openize-cells-gists / rename-excel-sheet-in-cshap.cs
Created May 30, 2024 10:22
This C# example showcases how to rename a MS Excel worksheet in C# using Openize.Cells SDK
using Openize.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);
@openize-cells-gists
openize-cells-gists / add-comments-into-worksheet.cs
Created May 22, 2024 13:03
This C# example illustrates how to add comments in Google Sheets / Excel Spread sheet using the Openize.Cells Sdk.
// 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
@openize-cells-gists
openize-cells-gists / open-existing-workbook.cs
Created May 22, 2024 13:03
This C# example showcases how to open an existing MS excel workbook and insert text into a specified cell using the Openize.Cells Sdk.
using Openize.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];
@openize-cells-gists
openize-cells-gists / insert-columns-into-worksheet.cs
Last active May 22, 2024 13:07
This C# example illustrates how to insert a specific number of columns into an Excel worksheet using the Openize.Cells Sdk. 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.
using Openize.Cells;
using (Workbook wb = new Workbook(filePath))
{
string startColumn = "B";
int numberOfColumns = 3;
Worksheet firstSheet = wb.Worksheets[0];
@openize-cells-gists
openize-cells-gists / insert-rows-into-worksheet.cs
Last active May 22, 2024 13:08
This C# example showcases how to programmatically insert rows into an Excel worksheet at a specified row index using the Openize.Cells Sdk.
using Openize.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;
@openize-cells-gists
openize-cells-gists / set-range-value-in-worksheet.cs
Last active May 22, 2024 13:06
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 Openize.Cells Sdk.
using Openize.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}");
@openize-cells-gists
openize-cells-gists / set-row-height-set-column-width-in-worksheet.cs
Created May 22, 2024 13:00
Code snippet to set the height of the Row and width of the Column within a worksheet.
using Openize.Cells;
// Initialize a new workbook instance
using (Workbook wb = new Workbook())
{
// Access the first worksheet in the workbook
Worksheet firstSheet = wb.Worksheets[0];
// Set the height of the first row to 40 points
firstSheet.SetRowHeight(1, 40);
@openize-cells-gists
openize-cells-gists / merge-cells-in-a-worksheet.cs
Created May 22, 2024 13:00
Code snippet to merge cells within a worksheet
using (var workbook = new Workbook())
{
var firstSheet = workbook.Worksheets[0];
firstSheet.MergeCells("A1", "C1"); // Merge cells from A1 to C1
// Add value to the top-left cell of the merged area
var topLeftCell = firstSheet.Cells["A1"];
topLeftCell.PutValue("This is a merged cell");
workbook.Save(filePath);
@openize-cells-gists
openize-cells-gists / extract-images-from-worksheet.cs
Created May 22, 2024 12:59
Code snippet to extract and save images from a worksheet to a specified directory
using Openize.Cells;
class Program
{
static void Main(string[] args)
{
string filePath = "Z:\\Downloads\\spreadsheet_test.xlsx"; // The path to your workbook
string outputDirectory = "Z:\\Downloads\\ExtractedImages"; // The directory where you want to save the extracted images
// Load the workbook from the specified file path