5 Answers, 1 is accepted
when i import from file。
Workbook wb;
using (FileStream SourceStream = File.Open(xlsxfilepath, FileMode.Open))
{
XlsxFormatProvider formatProvider = new XlsxFormatProvider();
wb = formatProvider.Import(SourceStream);
}
column width changed。
I Found When My Template File, In which Used "Normal" CellStyle , has Font isn't "Calibri",11, Example "宋体",12。
when I Import file,
WorkBook will Restore "Normal" CellStyle to "Calibri" And Sametime Column Width changed。
Workbook wb = ExcelWorkBookEngine.OpenWorkbook(@"C:\Users\Administrator\Desktop\test002.xlsx");
ExcelWorkBookEngine.SaveWorkbook(wb, @"C:\Users\Administrator\Desktop\test002_2.xlsx", out errmsg);
I Import File test002.xlsx And Save To File test002_2.xlsx
Column Width In File test002_2.xlsx is diff to Original File!
When I Midify "Calibri",11 As Normal Style, The Column Width will Keep !
Files In My Question List in Attach。
Can I Keep Column Width ?
Thank you for attaching the images. I created a spreadsheet with different column widths and changed the style to Times New Roman. After importing and exporting the file ti loaded as expected. Could you try whether this issue still appears with our latest Release version - R2 2018 SP1? If the issue still persists, please upload the sample document reproducing the problem. As this is a forum thread, you could either open a support thread or upload the document to an online files storage shared space.
Regards,
Peshito
Progress Telerik
If I want change the worksheet cloumn width,by the following:
worksheet.Columns[i].SetWidth(new ColumnWidth(width, true))
Problem is, width must is pixel unit。If Set width use Excel width unit, char count。
What is the Code?
The column width is between 0 and 255, which value represents the number of characters that can be displayed in a cell that is formatted with the standard font. You can find more information in "Change the column width and row height" article. To specify the appropriate unit, use Unit's class PointToDip method.
For example a column width set to 300 pixels is equal to 42.14 of the specified above units of measurement in Excel.
Regards,
Peshito
Progress Telerik