2
Answers

Self Join in SQL

Manish Sharma

Manish Sharma

12y
1.9k
1
Hi Friends

What is Self Join in SQL?
Answers (2)
0
Vulpes
NA 98.3k 1.5m 11y
I'm not familiar with this SDK or productivity tool at all but, judging by the link you posted, the cellAddress is what you'd expect i.e. "A1", "B2", "K5" etc.

Again based on the link, I'd have thought that the code you wanted would be on these lines:

public void SetBorderAndFill(WorkbookPart wbp1, WorksheetPart wsp1)
{
   Border border1 = GenData.GenerateBorder();
   Fill fill1 = GenData.GenerateFill();
   string celladdress = "K5"; // or whatever
   Cell cell7 = GenData.GetCell(wsp1, cellAddress);
   CellFormat cf1 = cell7.StyleIndex != null ? GenData.GetCellFormat(wbp1,    cell7.StyleIndex).CloneNode(true) as CellFormat : new CellFormat();
   cf1.FillId = GenData.InsertFill(wbp1, fill1);
   cf1.BorderId = GenData.InsertBorder(wbp1, border1);
   cell7.StyleIndex = GenData.InsertCellFormat(wbp1, cf1);
}
0
A Repasky
NA 231 119.5k 12y
That is why I said it must be in the wrong place.  Here is my code the way the article talked about it.  What should I use for cellAddress?









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.
0
Vulpes
NA 98.3k 1.5m 12y
The code should still work wherever you put it.

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? 
0
A Repasky
NA 231 119.5k 12y
It still has the same problem on the :
      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.<GetCell>b__0(Cell c) in c:\CLI\CS\DetailReport\GenData.cs:line 126
  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
0
Vulpes
NA 98.3k 1.5m 12y
It would appear that the SingleOrDefault method is being applied to a null sequence as I can't think what else could be null.

You could see if the exception goes away if you change the code to:

public static Cell GetCell(WorksheetPart workSheetPart, string cellAddress)
{
   var query = workSheetPart.Worksheet.Descendants<Cell>();
   if (query != null)
      return query.SingleOrDefault(c => cellAddress.Equals(c.CellReference));
   else
      return null;