DotNet ClosedXML Error
csimoneaux0527
Member Posts: 21
On the Report Comment Line I have added code to export to Excel. I am trying for the first time to utilize the following code.
Report line of code call
NewRow := NewRow + 1;
NewColumn := NewColumn + 1;
ExcelBuf.AddCell(NewRow, NewColumn,'Customer Comments',FALSE,TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text,'',0);
ExcelBuffer – Function
AddCell(CurrentRow_1 : Integer;CurrentCol_1 : Integer;Value : Variant;IsFormula : Boolean;IsBold : Boolean;IsItalics : Boolean;IsUnderline : Boolean;NumFormat : Text[30];CellType : 'Number,Text,Date,Time';Font : Text;FontSize : Integer)
GlobalRowNo := CurrentRow_1;
GlobalColumnNo := CurrentCol_1;
XlWrkShtDotNet.Cell(GlobalRowNo,GlobalColumnNo).Style.Font.Bold := IsBold;
Variable –
Name DataType Subtype
XlWrkShtDotNet DotNet ClosedXML.Excel.IXLWorksheet.'ClosedXML, Version=0.59.0.0,
Culture=neutral, PublicKeyToken=fd1eb21b62ae805b'
As soon as the following line is read ...
XlWrkShtDotNet.Cell(GlobalRowNo,GlobalColumnNo).Style.Font.Bold := IsBold;
I receive the following error
This message is for C/AL programmers: A DotNet variable has not been instantiated. Attempting to call ClosedXML.Excel.IXL.Worksheet.Cell in the Excel Buffer_CloseXML:AddCell
Can anyone help me please.
[-o<
Report line of code call
NewRow := NewRow + 1;
NewColumn := NewColumn + 1;
ExcelBuf.AddCell(NewRow, NewColumn,'Customer Comments',FALSE,TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text,'',0);
ExcelBuffer – Function
AddCell(CurrentRow_1 : Integer;CurrentCol_1 : Integer;Value : Variant;IsFormula : Boolean;IsBold : Boolean;IsItalics : Boolean;IsUnderline : Boolean;NumFormat : Text[30];CellType : 'Number,Text,Date,Time';Font : Text;FontSize : Integer)
GlobalRowNo := CurrentRow_1;
GlobalColumnNo := CurrentCol_1;
XlWrkShtDotNet.Cell(GlobalRowNo,GlobalColumnNo).Style.Font.Bold := IsBold;
Variable –
Name DataType Subtype
XlWrkShtDotNet DotNet ClosedXML.Excel.IXLWorksheet.'ClosedXML, Version=0.59.0.0,
Culture=neutral, PublicKeyToken=fd1eb21b62ae805b'
As soon as the following line is read ...
XlWrkShtDotNet.Cell(GlobalRowNo,GlobalColumnNo).Style.Font.Bold := IsBold;
I receive the following error
This message is for C/AL programmers: A DotNet variable has not been instantiated. Attempting to call ClosedXML.Excel.IXL.Worksheet.Cell in the Excel Buffer_CloseXML:AddCell
Can anyone help me please.
[-o<
0
Comments
-
I am using Nav 2013 NOT Nav 2013 R20
-
The error msg is very clear.
How to: Call .NET Framework Members from C/AL CodeThis message is for C/AL programmers: A DotNet variable has not been instantiated.0 -
You need to check the dot net variable is created first before writing in the cell.Regards,
Manish0 -
I do not understand what it means by "Not Instantiated" The message is not clear to me.
I am a beginner in the DotNet world. I am asking for help.
I did create the variable before writing the code.
How does one check the dot net variable is created first? I read the How To Call.Net but I do not understand it.
Normally I am not that dumb. the light bulb is just not coming on.
Please help.
[-o<
On The How To...
I listed my code in the original post
MyVariableName.ConstructorName(arguments);
XlWrkShtDotNet.Cell(GlobalRowNo,GlobalColumnNo).Style.Font.Bold := IsBold;
Variable –
Name DataType Subtype
XlWrkShtDotNet DotNet ClosedXML.Excel.IXLWorksheet.'ClosedXML, Version=0.59.0.0,
Culture=neutral, PublicKeyToken=fd1eb21b62ae805b'
When I used the C/AL Symbol Menu There was no Constructor listed. But the code did complie
I know I have missed something but I do not know what it is.0 -
Hi,
you may instantiate your dotnet variable like following:-
XMLWhiteCharCheck := XMLWhiteCharCheck.XMLCharWhiteList;
XlWrkBkDotNet := XlWrkBkDotNet.XLWorkbook();
you also refer following link for the same issue:-
http://www.dynamics.is/?p=7060
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 327 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions