arep
public static Cell GetCell(WorksheetPart workSheetPart, string cellAddress)
{
return workSheetPart.Worksheet.Descendants<Cell>().SingleOrDefault(c => cellAddress.Equals(c.CellReference));
}
System.NullReferenceException: Object reference not set to an instance of an object.
at DetailReport.GenData.<>c__DisplayClass1.
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at DetailReport.GenData.GetCell(WorksheetPart workSheetPart, String cellAddress) in c:\CLI\CS\DetailReport\GenData.cs:line 122
at DetailReport.Program.ExtractData(String product, String reporttitle, String whereClause, String lob) in c:\CLI\CS\DetailReport\Program.cs:line 168
at DetailReport.Program.GenDetailReports() in c:\CLI\CS\DetailReport\Program.cs:line 114
at DetailReport.Program.Main(String[] args) in c:\CLI\CS\DetailReport\Program.cs:line 36
It is called this way:

VulpesRank #55 · 29.2K reputationPosted Apr 13, 2013, 2:39 AM EDT
A RepaskyRank #8,108 · 228 reputationPosted Apr 13, 2013, 8:08 AM EDT
return query.SingleOrDefault(c => cellAddress.Equals(c.CellReference));
System.NullReferenceException: Object reference not set to an instance of an object.
at DetailReport.GenData.<>c__DisplayClass1.
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at DetailReport.GenData.GetCell(WorksheetPart workSheetPart, String cellAddress) in c:\CLI\CS\DetailReport\GenData.cs:line 126
at DetailReport.Program.ExtractData(String product, String reporttitle, String whereClause, String lob) in c:\CLI\CS\DetailReport\Program.cs:line 168
at DetailReport.Program.GenDetailReports() in c:\CLI\CS\DetailReport\Program.cs:line 114
at DetailReport.Program.Main(String[] args) in c:\CLI\CS\DetailReport\Program.cs:line 36
I think maybe I am putting it in the wrong place in the program. Here is the article that I am using as a basis for this.
http://stackoverflow.com/questions/15791732/openxml-sdk-having-borders-for-cell
VulpesRank #55 · 29.2K reputationPosted Apr 13, 2013, 9:57 AM EDT
If 'query' isn't null, then the only other thing that could produce an exception if it's null is the parameter 'cellAddress'.
So, are you sure that this isn't null when you pass it in?
A RepaskyRank #8,108 · 228 reputationPosted Apr 13, 2013, 7:04 PM EDT
Border border1 = GenData.GenerateBorder();Fill fill1 = GenData.GenerateFill();
string celladdress = null;
Cell cell7 = GenData.GetCell(wsp1, celladdress);
uint styleIndex = 7;
CellFormat cf1 = GenData.GetCellFormat(wbp1, styleIndex);
uint cfcount = GenData.InsertCellFormat(wbp1, cf1);
GenData.SetBorderAndFill(wbp1, wsp1);
Is the cell address like "K5"? That is the cell reference I thought. Are these calls out of order? I just used 7 for styleIndex. Just picked a number.
VulpesRank #55 · 29.2K reputationPosted Apr 14, 2013, 8:49 AM EDT