//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; // Auto fit column width of range 'A1' worksheet.Range["A1"].Value = "Document Solutions for Excel"; worksheet.Range["A1"].Columns.AutoFit(); //Auto fit row height of range 'B2' worksheet.Range["B2"].Value = "Document Solutions for Excel"; worksheet.Range["B2"].Font.Size = 20; worksheet.Range["B2"].Rows.AutoFit(); //Auto fit column width and row height of range 'C3' worksheet.Range["C3"].Value = "Document Solutions for Excel"; worksheet.Range["C3"].Font.Size = 32; worksheet.Range["C3"].AutoFit(); // Save to an excel file workbook.Save("AutoFit.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) ' Auto fit column width of range 'A1' With worksheet.Range!A1 .Value = "Document Solutions for Excel" .Columns.AutoFit() End With 'Auto fit row height of range 'B2' With worksheet.Range!B2 .Value = "Document Solutions for Excel" .Font.Size = 20 .Rows.AutoFit() End With 'Auto fit column width and row height of range 'C3' With worksheet.Range!C3 .Value = "Document Solutions for Excel" .Font.Size = 32 .AutoFit() End With ' save to an excel file workbook.Save("AutoFit.xlsx")