Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
Row height and column width is 0 when exporting XamDataPresenter to excel
posted

I followed the answer in this posts, which is similar to what I want to achieve:

http://forums.infragistics.com/forums/t/38674.aspx

When I open the excel file the data has been correctly written, but row height and column width of the exported area has been set to 0 so it appear as hidden.

I have a DataTable with the content I want to export, then I make a XamDataPresenter and set the source to be the DataTable:

var dataPresenter = new XamDataPresenter();
dataPresenter.BeginInit();
dataPresenter.DataSource = dataTable.DefaultView;
dataPresenter.EndInit();
return dataPresenter;

Then I make a new workbook and export the dataPresenter to the file:

var workbook = new Workbook(WorkbookFormat.Excel97To2003);
var worksheet = workbook.Worksheets.Add(destinationSheet);
_excelExporter.Export(dataPresenter, worksheet);

But as I said, the heigth and width of the rows and columns in the Excel sheet is 0 so it appear as hidden.

I've managed to do a workaround, by setting the size of rows and columns in the sheet manually after the export:

for (var colum = 0; colum < dataTable.Columns.Count; colum++)
    worksheet.Columns[colum].Width = 4257;

for (var row = 0; row < dataTable.Rows.Count+1; row++)
    worksheet.Rows[row].Height = 345;

But this is time-consuming so is it a other way to set this through fieldlayouts or similar?

I have also tried setting the default height and width in the worksheet and as fieldsettings on the dataPresenter before exporting with no effect:

worksheet.DefaultRowHeight = 345;
worksheet.DefaultColumnWidth = 4257;

dataPresenter.FieldSettings.CellWidth = 1632;
dataPresenter.FieldSettings.CellHeight = 1632;

 

Any tips and help would be most appreciated.

Parents
No Data
Reply
  • 3255
    posted

    Hello,

    I did not hear from you so just checking if you were able to resolve your issue. Please let me know if there is anything I can help with on this issue.

Children
No Data