Last active
December 9, 2023 09:20
-
-
Save aspose-com-kb/e648479facc324d03f568be4f695df47 to your computer and use it in GitHub Desktop.
Autofit Rows and Columns in Excel using C#. For further details: https://kb.aspose.com/cells/net/autofit-rows-and-columns-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 System; | |
using Aspose.Cells; | |
class Program | |
{ | |
static void Main(string[] args) // Autofit Excel file using C# | |
{ | |
new License().SetLicense("License.lic"); | |
// Load the Excel file | |
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook("autofit.xlsx"); | |
// Get reference of desired worksheet | |
Aspose.Cells.Worksheet worksheet = workbook.Worksheets[0]; | |
// Auto fit the columns and rows | |
worksheet.AutoFitRows(); worksheet.AutoFitColumns(); | |
// Save workbook | |
workbook.Save("autofit-excel.xlsx"); | |
Console.WriteLine("Done"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment