is there any way to export the data from infragistics ultraweb grid to a specific excel file which is havinng some formats?
say i have my template in \Templates folder in my server. (i.e \Templates\UserTemplate.xls) i want to write my data from the webgrid to this excel. our server may not have excel installed so i am using infragistics.excel.
thanks
arun.k.s
atmy@chevron.com
You can try loading your own .XLS workbook into an Infragistics.Excel Workbook object using its Load method. If there is anything the Workbook object doesn't recognize, it will try to preserve it as-is for when you Save the workbook back to a file or for transmission to the end user.
You can also direct WebGridExcelExporter to begin exporting at a specific position on a Worksheet by setting its ExcelStartRow and ExcelStartColumn properties. Left to its own designs, at this point WebGridExcelExporter will start writing out your WebGrid in rectangular fashion with the specified cell as the top, left corner of a rectangular region. If there is any formatting underneath where the exporter is writing, it will probably be overwritten. If even further fine grained control is necessary, there are a number of events you can handle (for example, to put the first 100 rows on Sheet1, the second 100 rows on Sheet2, etc.)
So this should work relatively easily if your template has a nice rectangular region in it for where you want the WebGrid to be exported, and all the customizations are around the margins or before the start of the exported WebGrid at the top of the Worksheet. As your template worksheet grows more complex, the more likely you're going to need to direct the export so it retains your areas of custom formatting.
One thing WebGridExcelExporter will do is resize the Worksheet columns where it exports cell values because it tries to guarantee the column is at least as wide as the widest cell value. If you have a column formatted to a specific width in your template for some reason, then this behavior may actually lead that column width to become narrowed. You can stretch the columns back to your desired width (measured in twips) in the EndExport event.https://es.infragistics.com/help/aspnet/web-webexcelexporter
Hi,
I wanted to know how to convert the length of a column in ultrawebgrid which is in pixels to that in excel(integer).
For example if the size of column1 is 150px then in excel the size could be 2500 (which is an integer)
Dim owb As Workbook = New Infragistics.Excel.Workbook()Dim len1 As Unitlen1 = UltraWebGrid1.Columns(0).Widthowb.Worksheets.Item(0).Columns(0).Width = len ' this gives me an error
owb.Worksheets.Item(0).Columns(0).Width = len.value ' this works fine. But the width of column on excel is very small and is not visible.
If I multiply len.value by a number then things works but I want the actual convertion factor which should be used.
Thanks,
Junaid.
The width of the column is in 1/256ths of the average character width of the default font of the workbook. The exported workbook's always use Arial font, but the font height can change. You can determine the font height in points by getting the Workbook's DefaultFontHeight property, which is in twips, and dividing by 20. Then determine how wide the '0' character is without padding in GDI using a graphics object:
Size size;
using ( Font font = new Font( "Arial", (float)( workbook.DefaultFontHeight / 20.0 ) ) size = TextRenderer.MeasureText( grfx, "0", font, Size.Empty, TextFormatFlags.NoPadding )
int width = size.Width;
Multiple the number of pixels you would like to make your column by 256 and divide by the width of the zero character. The result is the width you should set on your column.