Hello support team,
I am using your last version of Lightswitch <ExtensionAssembly>InfragisticsSL4.Controls.Grids.XamGrid.v11.2 and I would like to know how can I export data form Grid to excel.
Thank you for support
Libor
Hello Libor,
This is just a follow up if you require any further assistance.
Hi Duane,
thank you for example, but I am working with LightSwitch and I do not know how to add the Infragistics reference to LightSwitch project.
For adding the references you can add within a Silverlight Class Library. An example can be found in the following link: http://blogs.infragistics.com/blogs/mihail_mateev/archive/2010/09/04/creating-a-visual-studio-lightswitch-custom-silverlight-control-using-infragistics-components.aspx.
I am not able to create export to excel in LightSwitch project.
Do you have any example (in LightSwitch project) where it si shown how to export data from Infragistics grid to excel in LightSwitch? It would help.
Thank you
I have looked for any feature for exporting to excel from the Infragistics Grid directly and have not found any example. For any questions you can follow up with the email: DSManager@infragistics.com providing the product id of the request.
Hello Duane,
first of all, thank you for support.
The conclusion is: "Infragistics grid component for LightSwitch" application does not offer the ability to export data to MS Excel, either directly (in the designer) or indirectly by using code.
Did I understand it correctly?
The above code is a Silverlight solution. When running the application uses a Silverlight Class Libray in order to run in LightSwitch project and would be necessary if you would like to export to excel. As far as exporting from the Infragistics Grid directly I have submitted this as a product idea and the ID of the request is PI12060139.
When using the features from LightSwitch controls such as the Infragistics Grid there would be no code necessary. An example of the requirements of this control can be found here: http://help.infragistics.com/NetAdvantage/LightSwitch/2012.1/CLR4.0?page=Grid_Getting_Started_with_Infragistics_Grid.html.
Thank you for example.
Maybe I explained it correctly, but I need to export data directly from Infragistics Grid in LighSwitch which is part of the project. This means that I have more LightSwitch forms (screens) and each form using Infragistics grid (in screen designer I have selected Infragistics Grid instead of Data Grid).
Then I have the button (on the screen) to which I assign the following code:
partial void ExportToExcel_Execute() { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.DefaultExt = "xlsx"; saveDialog.Filter = "Excel Workbook (.xlsx)|*.xlsx"; if (saveDialog.ShowDialog().Value) { try { // Create a Workbook object with one Worksheet Infragistics.Documents.Excel.Workbook workbook = new Infragistics.Documents.Excel.Workbook(); Infragistics.Documents.Excel.Worksheet worksheet = workbook.Worksheets.Add("sheet1"); workbook.SetCurrentFormat(WorkbookFormat.Excel2007); // Export the xamGrid data to the Workbook object excelExporter.Export(dataGrid, workbook); Stream stream = saveDialog.OpenFile(); // Save the file using the Save method of the Workbook object. workbook.Save(stream); stream.Close(); } catch (Exception exc) { MessageBox.Show(exc.Message); } } }
My questions are as follows:
===================== - Is my assumption correct? Can I use this code directly in LightSwitch project without having to refer to any external control (user control with Infragistics Grid inside)? In your attached example you have spatial usercontrol on LightSwitch screen but I would like to have direct reference to Infragistics grid object.
- Which Infragistics library, and where (I assume that the client's project) I have to reference in the project?
- How do I refer to the DataGrid object in this line of code in LightSwitch project? excelExporter.Export (DataGrid, workbook)
For exporting to excel in Silverlight Class Library I have attached a sample.