Hello,
I'm currently using Aspose.Cells for .NET (7.4.0.0). I'm running the component within SharePoint 2010 on the .NET 2.0 Framework. Currently, when I use Worksheet.AutoFitColumn(x), I get the following error message (including thread).
Exception information:
Exception type: NullReferenceException
Exception message: Object reference not set to an instance of an object.
Thread information:
Thread ID: 7
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at ..(String , Int32 , FontStyle )
at ..( , Int32 , RectangleF )
at ..(Graphics , Cells , Int32 , Int32 , Int32 , Int32 , AutoFitterOptions )
at ..AutoFitColumn(Cells , Int32 , Int32 , Int32 , Int32 , AutoFitterOptions )
at Aspose.Cells.Worksheet.AutoFitColumn(Int32 columnIndex)
at LeapSeedCommon.DataManager.RecordSearch.InsertExcelExportHeader(Worksheet xDoc, LeapSeedSection ExportSec, String GroupSort)
at LeapSeedCommon.DataManager.RecordSearch.GenerateExcelExportFile(String SQL, String ExportOpt, Workbook aspApp, Int32 Section_ID, String GroupSort, Hashtable HashStyles, ReaderProvider rpLocal, ReaderProvider rpExt)
at LeapSeedCommon.DataManager.RecordSearch.ExportSearchResultsToExcel(ReaderProvider& rpLocal, ReaderProvider& rpExt, HttpResponse& Response)
at ASP._layouts_leapseed_data_manager_export_excel_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\template\layouts\leapseed\data_manager\export_excel.aspx:line 39
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
It's worth noting I noticed this in Aspose 7.3.5 as well. Also, When I use the exact same code outside of SharePoint in a .NET 4.0 application, everything works fine. So I wouldn't be surprised if this issue is specific to how Aspose.Cells works with .NET 2.0.
Below is the function the error occurs in.
Protected Overridable Sub InsertExcelExportHeader( _
xDoc as Aspose.Cells.WorkSheet, _
ExportSec as LeapSeedSection, _
GroupSort as String _
)
' LOCAL VARIABLES
Dim X as Integer ' Loop Variable
Dim realX as Integer ' Real Loop Variable
Dim aspApp = xDoc.Workbook
X = 0
FOR realX = 0 TO ExportSec.Elements.Length - 1
If GroupSort <> ExportSec.Elements(realX).FieldName Then
' EXCEL Specific.
xDoc.Cells(0, X).PutValue(ExportSec.Elements(realX).Label)
Dim xStyle As Aspose.Cells.Style = xDoc.Cells(0, X).GetStyle()
xStyle.Pattern = BackgroundType.Solid
xStyle.ForegroundColor = System.Drawing.Color.Black
xStyle.Font.Color = System.Drawing.Color.White
xStyle.HorizontalAlignment() = Aspose.Cells.TextAlignmentType.Center
xStyle.Font.Size = 12
xStyle.Font.IsBold = True
xDoc.Cells(0, X).SetStyle(xStyle)
xDoc.AutoFitColumn(X) <--------- ERROR OCCURS HERE
X += 1
End If
NEXT
End Sub ' Field_Data
Please also note that I am not loading a template in; Aspose is starting with a blank worksheet.
I hope you can help. We'd really like to be able to sell your components for our projects.
Thanks,
Paul