We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Resize to fit

Hi The grid that I am exporting to Excel has columns of varying widths. When I open up the Excel file, part of the columns appear "chopped off" because the text in the longer columns is not completely displayed. Is there some sort of resize function call for a range of cells that can be called. I remember that we have a call like this for the Syncfusion grids to automatically update row and column heights after the data is filled. I am looking for something similar for the Excel gird that I create. I dont know what the height/width could be and so cannot use row.height or column.width. Thanks Arun

6 Replies

AD Administrator Syncfusion Team April 13, 2004 07:19 PM UTC

Hi Arun, Currently this feature is not supported in Essential ExcelRW. We will be adding this feature shortly after the release of version 2.0. However the release version of 2.0 will include a sample that autosizes column widths by manually measuring the width of the string using the measurestring method of the graphics object. I can send you a sample if you provide me more more information on the type of grid that you are using. Sorry for the inconvenience. Thank you for your co-operation. Best regards, Stephen. >Hi > >The grid that I am exporting to Excel has columns of varying widths. When I open up the Excel file, part of the columns appear "chopped off" because the text in the longer columns is not completely displayed. > >Is there some sort of resize function call for a range of cells that can be called. I remember that we have a call like this for the Syncfusion grids to automatically update row and column heights after the data is filled. > >I am looking for something similar for the Excel gird that I create. I dont know what the height/width could be and so cannot use row.height or column.width. > >Thanks >Arun


AB Arun Balakrishnan April 14, 2004 09:30 PM UTC

Hi Stephen Thansk for your reply I am trying to write a function that exports out an ordinary Syncfusion grid to Excel. I have already resized all the columns in the Syncfusion grid and have stored their widths in pixels in an array. I want to set the corresponding widths of the columns of the Excel sheet but dont know how to convert the widhts from pixels to the unit that Excel needs (number of characters ??) If your can help me out with the example you mentioned in your reply or by letting me know what function I have to call in the ExcelRW API to convert the pixels into for proper display in Excel,then that would be great. Thanks and regards Arun >Hi > >The grid that I am exporting to Excel has columns of varying widths. When I open up the Excel file, part of the columns appear "chopped off" because the text in the longer columns is not completely displayed. > >Is there some sort of resize function call for a range of cells that can be called. I remember that we have a call like this for the Syncfusion grids to automatically update row and column heights after the data is filled. > >I am looking for something similar for the Excel gird that I create. I dont know what the height/width could be and so cannot use row.height or column.width. > >Thanks >Arun


AD Administrator Syncfusion Team April 15, 2004 01:53 PM UTC

Hi Arun, The autofit property in MS Excel is a designer property. Microsoft uses an internal algorithm that is not known to do the conversion between pixels and the display height/width. The workaround for this is to manually measure the lengths of the strings in the cells and use an approximate scaling factor to convert the pixels to appropriate measurements. This method is not available in the current ExcelRW API. However we will be adding this functionality shortly. The development team will implement a better algorithm to do the conversion. As a temporary workaround i have been using the following scaling sheet.Range[i,j].ColumnWidth = (grid.ColWidths[j]/7.43); sheet.Range[i,1].RowHeight = (grid.RowHeights[i]/1.33); This scaling factor seems to work fine for me. I have a sample that exports the contents of a GridControl to excel. You will not be able to run the sample because it uses some of the new methods that were added for the final release. I am attaching it in case you might find something useful in the ExportToExcel method that exports the grid control. ExportToExcel_7500.zip Thanks you for your co-operation in this issue. Please let me know if you any any other questions. Best regards, Stephen. >Hi Stephen > >Thansk for your reply > >I am trying to write a function that exports out an ordinary Syncfusion grid to Excel. I have already resized all the columns in the Syncfusion grid and have stored their widths in pixels in an array. > >I want to set the corresponding widths of the columns of the Excel sheet but dont know how to convert the widhts from pixels to the unit that Excel needs (number of characters ??) > >If your can help me out with the example you mentioned in your reply or by letting me know what function I have to call in the ExcelRW API to convert the pixels into for proper display in Excel,then that would be great. > >Thanks and regards >Arun > >>Hi >> >>The grid that I am exporting to Excel has columns of varying widths. When I open up the Excel file, part of the columns appear "chopped off" because the text in the longer columns is not completely displayed. >> >>Is there some sort of resize function call for a range of cells that can be called. I remember that we have a call like this for the Syncfusion grids to automatically update row and column heights after the data is filled. >> >>I am looking for something similar for the Excel gird that I create. I dont know what the height/width could be and so cannot use row.height or column.width. >> >>Thanks >>Arun


GR Greg May 14, 2004 07:09 PM UTC

Actually, the algorithm that MS uses for column width in characters is published: http://support.microsoft.com/?kbid=214123 Unfortunately, ExcelRW does not yet support Application.StandardFont (always Tahoma). For Row height (in points), I am confused as to what ExcelRW Application.InchesToPoints(1) does. I get 11.248593925759279 points/inch, which when compared to the RowHeight I get, seems very far off the mark. However, if I just use 72 points/inch, things look better. Maybe someone could elaborate on this. -Greg


AD Administrator Syncfusion Team May 15, 2004 03:24 PM UTC

Hi Greg, Thanks for the link to the KB article. I have contacted the developer for his input on this issue. I will update this post as soon as i hear from him. Also, Some of the issues you had posted have been fixed. Could you please let me know if you are using an evaluation version so that i can send you a custom evaluation build. Thanks. Best regards, Stephen. >Actually, the algorithm that MS uses for column width in characters is published: >http://support.microsoft.com/?kbid=214123 > >Unfortunately, ExcelRW does not yet support Application.StandardFont (always Tahoma). > >For Row height (in points), I am confused as to what ExcelRW Application.InchesToPoints(1) does. I get 11.248593925759279 points/inch, which when compared to the RowHeight I get, seems very far off the mark. However, if I just use 72 points/inch, things look better. Maybe someone could elaborate on this. > > >-Greg


GR Greg May 15, 2004 11:58 PM UTC

Stephen, I am a customer. Feel free to email me. I do not have your email address. My "list" has gotten quite large. I hope that you''ve been putting these issues into your wonderful Direct-Trac so we don''t lose them; don''t rely on your customers to do that work! ;-) I like the OPEN forums. Too bad the community of users don''t yet respond to others'' issues more often. Thanks, Greg

Loader.
Live Chat Icon For mobile
Up arrow icon