Hi,in XamGrid I want to export the data to excel;in your control XamDataGrid I can use the DataPresenterExcelExporter-Class.Is there a way to use the DataPresenterExcelExporter-Class in XamGrid?Thanks voks
Hi Cloud,
On which line is the NullReferenceException occuring? The debugger should tell you where the exception occurs.
The only reason I can see from the code you provided that would cause an exception is the line where you set the DataPresenterExcelExporter equal to the exporter you pull from the Resources collection. That line will return null if it can't find the item you're looking for.
i also have a problem with the export to excel. i simply want to export my whole xamdatagrid to excel like in this tutorial
http://www.youtube.com/watch?v=dtn9oa_Yz_0:
but in this code:
string fileName = @"C:\Temp\tmp.xlsx"; DataPresenterExcelExporter exporter = (DataPresenterExcelExporter) this.Resources["excelExporter"]; ExportOptions options = new ExportOptions(); options.FileLimitBehaviour = FileLimitBehaviour.ThrowException;
xporter.Export(grid,filename,WorkbookFormat.Excel2007, options); System.Diagnostics.Process p = new Process(); p.StartInfo.FileName = fileName; p.Start();
i got a NullReferenceException but i don´t get where and why this happens.
all of my objects are set....
what am i doing wrong?
regards
Cloud
Hi Abu,
I think this forum post will help you out with this. http://ko.infragistics.com/community/forums/p/70154/355472.aspx#355472
Keep in mind that the sample provided here is for Silverlight but it uses the Infragistics Excel framework so the code for exporting will be the same as in WPF.
Hi All,
In my xamgrid I use groupby like this
<ig:XamGrid ItemsSource="{Binding}">
<ig:XamGrid.Columns> <ig:TextColumn HeaderText="Code" Key="Code" Width="100" IsReadOnly="True"></ig:TextColumn> <ig:TextColumn HeaderText="Name" Key="DisplayName" Width="180" IsGroupBy="True" IsReadOnly="True"></ig:TextColumn>
</ig:XamGrid.Columns></ig:XamGrid>
My Question is:
In WPF, How can I display the groupby-record in the excel-worksheet in a grouped way.
Please give provide me a sample solution.
voks said: My Question is: How can I display the groupby-record in the created excel-worksheet in a grouped way.You can see a sample of grouped-excel-output (and this is, what I want to implement),if you export grouped data from xamdatagrid to excel.
How can I display the groupby-record in the created excel-worksheet in a grouped way.You can see a sample of grouped-excel-output (and this is, what I want to implement),if you export grouped data from xamdatagrid to excel.
This will require a little formatting on your part to achieve the same kind of look. For instance, each GroupByRow object is like a header for the grouped rows contained within it. When you output this object, you can merge the cells horizontally for the current WorksheetRow that you are on and then set the value for this merged region to the value in the GroupByRow.http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=InfragisticsExcelEngine_Merge_Cells.html
Then for Rows inside the GroupByRow you will need to shift over to the next cell to create an indent that visually shows that this row data belongs to the above GroupByRow header. For that you can do something like the following:
// This value would be affected depending on how much should be indented on the current row.int indentAmount = 1;
// inside the code that iterates through the columns...worksheetRow.Cells(columnIndex + indentAmount).Value = gridRow.Cells(columnIndex).Value;
anant_9sept said: I have similar problem.. but I have different senario. I have 3 XamaDataGrid on form and I want to Export all grids it to one excel on different sheets. How can I do that.
I have similar problem.. but I have different senario.
I have 3 XamaDataGrid on form and I want to Export all grids it to one excel on different sheets.
How can I do that.
The DataPresenterExcelExporter.Export method has an overload that takes in a worksheet so you can create a Workbook and then multiple Worksheets inside the Workbook and give the Export method one of these worksheets. You will need to call Export for every XamDataGrid you want to export and pass it its associated worksheet.
// inside the export button click event...dataPresenterExcelExporter.Export(xamDataGrid1, worksheet1);dataPresenterExcelExporter.Export(xamDataGrid2, worksheet2);dataPresenterExcelExporter.Export(xamDataGrid3, worksheet3);
Once your worksheets are filled out you can save the workbook to a file.http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=InfragisticsExcelEngine_Save_a_Workbook.html