We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Cells 5.1.3 after upgrade from 4.x version error processing smart tags

<p> We have upgraded to the latest Dll to handle processing smart tags for rows over 65K limit of excel 2003, the problem is when we are encoutering this line:</p><p>template.Process(template.Workbook.Worksheets[<font size="2" color="#a31515"><font size="2" color="#a31515">"Data"</font></font><font size="2">].Index, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">false</font></font><font size="2">);</font></p><p><font size="1">we get a generic system Null exception. TIA</font></p><p>Here is the code snippet:</p><font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">var</font></font><font size="2"> template = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">WorkbookDesigner</font></font><font size="2">();</font><font size="2"> <p><font size="2" color="#008000"><font size="2" color="#008000">//template.Workbook.Open(inFile);</font></font></p></font><font size="2"><p><font size="2" color="#008000"><font size="2" color="#008000">//template.Workbook.Open(new MemoryStream(fileBytes), FileFormatType.Excel2007Xlsm);</font></font></p></font><font size="2">template.Workbook = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">Workbook</font></font><font size="2">(</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">MemoryStream</font></font><font size="2">(fileBytes), </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">LoadOptions</font></font><font size="2">(</font><font size="2" color="#2b91af"><font size="2" color="#2b91af">LoadFormat</font></font><font size="2">.Xlsx));</font><font size="2"> <p><font size="2" color="#008000"><font size="2" color="#008000">//Insert data for each dataset</font></font></p></font><font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">var</font></font><font size="2"> nodata = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">false</font></font><font size="2">;</font><font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">foreach</font></font><font size="2">(</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">var</font></font><font size="2"> dataSet </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">in</font></font><font size="2"> dataSets)</font><font size="2"> <p>{</p><p><font size="2" color="#0000ff"><font size="2" color="#0000ff">var</font></font><font size="2"> pivotData = dataSet.Value.GetData(requestId, dataSet.Key);</font></p></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">if</font></font><font size="2">(pivotData.Count < 1)</font><font size="2"> <p>{</p>nodata = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">true</font></font><font size="2">;</font><font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">continue</font></font><font size="2">;</font><font size="2"> <p>}</p>nodata = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">false</font></font><font size="2">;</font><font size="2"> <p>template.SetDataSource(pivotData[0].GetClassName(), pivotData);</p><p>template.Process(template.Workbook.Worksheets[<font size="2" color="#a31515"><font size="2" color="#a31515">"Data"</font></font><font size="2">].Index, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">false</font></font><font size="2">);template.Workbook.Worksheets[</font></p></font><font size="2" color="#a31515"><font size="2" color="#a31515">"Data"</font></font><font size="2">].AutoFitColumns();</font><font size="2"> <p>}</p></font>
This message was posted using Aspose.Live 2 Forum

Aspose.Cells 5.1.3 after upgrade from 4.x version:

We have upgraded to the latest Dll to handle processing smart tags for rows over 65K limit of excel 2003, the problem is we are encoutering a generic null exception on this line but we only get this error if the data set containes over 65K records:

template.Process(template.Workbook.Worksheets["Data"].Index, false);

here is the complete code snippet:

var template = new WorkbookDesigner();
//template.Workbook.Open(inFile);
//template.Workbook.Open(new MemoryStream(fileBytes), FileFormatType.Excel2007Xlsm);

template.Workbook = new Workbook(new MemoryStream(fileBytes), new LoadOptions(LoadFormat.Xlsx));

//Insert data for each dataset
var nodata = false;
foreach(var dataSet in dataSets)
{
var pivotData = dataSet.Value.GetData(requestId, dataSet.Key);
if(pivotData.Count < 1)
{
nodata = true;
continue;
}
nodata = false;
template.SetDataSource(pivotData[0].GetClassName(), pivotData);
template.Process(template.Workbook.Worksheets["Data"].Index, false);
template.Workbook.Worksheets["Data"].AutoFitColumns();
}

Hi,

Thanks for details and the code. Please share the template file with us so that we can perform testing. This will help us to find out the root cause of the issue.

Thanks,

I have done alot of testing, the code listed is generic code and no matter what the dataset provided to the process method looks like the line fails.

the number of records in the dataset must be more than the excel 2003 limit of 65K and you can create any template your want with at least 1 smart tag as long as the smart tag is a formula such as &=&=A{r}*B{r}

hope this helps