hello,
I am using Infragistics wingrid and c#.I am using the Excel Export Functionality to create a .xlsx file.We have written some code for formatting the exported columns from the grid but we are getting unexpected errors as Unable to merge or the columns are exported in wrong arrangement like :
we have one main grid and several child grids , we want the columns of parent grid to be displayed first then the columns of child grid should be displayed but the columns are displayed in a manner like 1st 2 columns of parent are added then 1 of child etc.
Can you please help us , i have registered version of ingragistics.
Thanks & Regards,
Seema Sharma
Hello Seema,
I`m not sure that I understand well your scenario, but I try to reproduce it in a small sample. Could you please take a look at the attached sample and if you think that I didn`t reproduce your issue, feel free to modify this sample and revert it back to me. I`ll be glad to research it for you.
Let me know if you have any questions.
Regards
this is the sample
If you need any additional assistance don’t hesitate to ask.
hi,
Thanks for the post but it doesnt solve our purpose.
I am using Infragistics 11.2 with visual studio 2010.I have used for header formatting but object e is throwing null reference error which was rather working fine in infragistics 2003.7.Please help me in the same.
public void HeaderCellExported(HeaderCellExportedEventArgs
e)
{
string
msn;
//string msn_prec;
if (e.GridHeader.Column.Tag != null
)
if (e.GridHeader.Column.Tag.Equals("TEMP_COL"
))
msn = e.GridHeader.Column.Tag.ToString();
e.CurrentWorksheet.Rows[e.CurrentRowIndex - 1].Cells[e.CurrentColumnIndex].Value =
BusProject.GetInstance().GetCurrentProjectName() + "-TEMP MSN"
;
// Récupération du format
IWorksheetCellFormat
cellFormat = e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].CellFormat;
e.CurrentWorksheet.Rows[e.CurrentRowIndex - 1].Cells[e.CurrentColumnIndex].CellFormat.SetFormatting(cellFormat);
tempColCount++;
if
(msn != currentMsn) currentMsn = msn;
else if (currentMsn != ""
&& nbofvisibleTEmpcount == tempColCount)
e.CurrentWorksheet.MergedCellsRegions.Clear ();
WorksheetMergedCellsRegion
region = e.CurrentWorksheet.MergedCellsRegions.Add(e.CurrentRowIndex - 1, e.CurrentColumnIndex - (nbofvisibleTEmpcount-1),
e.CurrentRowIndex - 1, e.CurrentColumnIndex);
}
//if (currentMsn != "" && tempColCount == 3)
//{
// WorksheetMergedCellsRegion region = e.CurrentWorksheet.MergedCellsRegions.Add(e.CurrentRowIndex - 1, e.CurrentColumnIndex - 2,
// e.CurrentRowIndex - 1, e.CurrentColumnIndex);
//}
//if (currentMsn != "" && tempColCount == 2)
// WorksheetMergedCellsRegion region = e.CurrentWorksheet.MergedCellsRegions.Add(e.CurrentRowIndex - 1, e.CurrentColumnIndex - 1,
// }
else
"MSN "
+ msn;
region = e.CurrentWorksheet.MergedCellsRegions.Add(e.CurrentRowIndex - 1, e.CurrentColumnIndex - 1,
/*msn = e.GridHeader.Column.Tag.ToString();
msn_prec = "";
if (firstColumnToMerge == 0) firstColumnToMerge = e.CurrentColumnIndex;
if (e.CurrentWorksheet.Rows[e.CurrentRowIndex-1].Cells[e.CurrentColumnIndex-1].Value != null)
msn_prec = e.CurrentWorksheet.Rows[e.CurrentRowIndex-1].Cells[e.CurrentColumnIndex-1].Value.ToString();
// copie du msn
e.CurrentWorksheet.Rows[e.CurrentRowIndex-1].Cells[e.CurrentColumnIndex].Value = "MSN "+ msn;
IWorksheetCellFormat cellFormat = e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].CellFormat;
e.CurrentWorksheet.Rows[e.CurrentRowIndex-1].Cells[e.CurrentColumnIndex].CellFormat.SetFormatting(cellFormat) ;
if (e.GridHeader.Column.Key.EndsWith("RevAchDates"))
WorksheetMergedCellsRegion region = e.CurrentWorksheet.MergedCellsRegions.Add(e.CurrentRowIndex-1,firstColumnToMerge,
e.CurrentRowIndex-1,e.CurrentColumnIndex);
firstColumnToMerge = 0;
}*/
//if (!e.GridRow.Band.Columns.Exists("C_ACTION_ID")) nbColumnsMilestones = e.CurrentColumnIndex;
//Rename the column header Responsible into Milestone Responsible in order to not confuse with column Responsible of actions when we repositionne
//actions columns
(e.CurrentColumnIndex > lastMilestoneColumn) lastMilestoneColumn = e.CurrentColumnIndex;
if (e.GridRow.Band.Key == BusMilestonesDates
.CNameMonitoredMilestones)
//if (!e.GridRow.Band.Columns.Exists("C_ACTION_ID"))
nbColumnsMilestones = e.CurrentColumnIndex;
else if (e.GridRow.Band.Key == BusMilestonesDates
.CNameRelMilestonesLinks)
nbColumnsLink = e.CurrentColumnIndex;
//Rename the column header Due Date into MILESTONE in order to not confuse with column Due Date of actions when we repositionne
if (e.GridHeader.Caption == "Responsible"
if (e.GridHeader.Band.Key == BusMilestonesDates
e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].Value =
"Responsible"
Hello seema,
Thanks for attached code, but could you please upload a whole sample, that we could build and reproduce your issue.
Thanks and Regards
Hi,
There are other types of headers besides column headers. There's the grid header (which I don't exports, anyway), but there are also Group headers. So you are probably getting into that event for a Group header and so the column is null.
So just check to see if the Column is nothing and then skip your code that tries to access the Tag.
(not e.GridHeader.Column is nothing andalso e.GridHeader.Column.Tag != null)
The column value is null , but it was working fine in prior version without any change in the code (above specified).
I m not getting how to resolve this , can you please help me.
The column is not null when we use the same code for infragistics 2003.7
Seema Sharma.
My guess is that Column is null. So you should check to make sure e.GridHeader.Column is not Nothing before you try to access the Tag property.
Could you please tell me the exact place in your source code, where is throwing null reference exception ?