Last active
May 12, 2022 17:37
Code to Set Width of Cell in Excel using C#. A detailed article is available here for further description: https://kb.aspose.com/cells/net/how-to-set-width-of-cell-in-excel-using-csharp/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Cells; | |
namespace SetWidthOfCellInExcelUsingCSharp | |
{ | |
class Program | |
{ | |
static void Main(string[] args) // Main function to set width of cell in CSharp | |
{ | |
// Instantiate the license to remove trial version watermark in the output Excel file | |
Aspose.Cells.License licForCells= new Aspose.Cells.License(); | |
licForCells.SetLicense("Aspose.Svg.lic"); | |
// Create a workbook class object to set column width | |
Workbook wb = new Workbook(); | |
// Access the first worksheet from the default collection of worksheets | |
Worksheet ws = wb.Worksheets[0]; | |
// Set the column width to 20.0 | |
ws.Cells.SetColumnWidth(1, 20.0); | |
// Saving the Excel file having specified column width | |
wb.Save("output.xlsx"); | |
System.Console.WriteLine("Done"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment