Problem about SaveExcel

Posted by: rika on 8 September 2017, 12:46 pm EST

  • Posted 8 September 2017, 12:46 pm EST

    <P>Hi all, </P>
    <P>I'm using the Spread for Windows Forms v3 for VS2005.<BR>Now, I have a trouble with SaveExcel Command.</P>
    <P>I want to export excel from the spread that uses ColumnSpan and RowSpan.</P>
    <P>But, when i use SaveExcel Command to export data, i got NullReference Exception.<BR>I have tried some Options(SaveFlags) and I found that I can export data with using the DataOnly.</P>
    <P>How can i export data from spread that used ColumnSpan and RowSpan?</P>
    <P>OK -- FpSpread1.SaveExcel(sFileName, FarPoint.Excel.ExcelSaveFlags.DataOnly)<BR>NG -- FpSpread1.SaveExcel(sFileName, FarPoint.Excel.ExcelSaveFlags.SaveBothCustomRowAndColumnHeaders)</P>
    <P>My sample source is here...<BR>------------------------------------------<BR>Public Class Form1</P>
    <P>    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<BR>        Dim sFileName As String<BR>        Dim fbd As New FolderBrowserDialog<BR>        If fbd.ShowDialog() = Windows.Forms.DialogResult.OK Then</P>
    <P>            sFileName = fbd.SelectedPath & "\" & "a.xls"<BR>            FpSpread1.SaveExcel(sFileName, FarPoint.Excel.ExcelSaveFlags.SaveBothCustomRowAndColumnHeaders)<BR>        End If</P>
    <P>    End Sub</P>
    <P>    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR>        With FpSpread1.ActiveSheet<BR>            .ColumnHeader.Cells(0, 0).Value = "aaa"<BR>            .ColumnHeader.Cells(0, 0).ColumnSpan = 2<BR>            .Cells(0, 0).Value = "a"<BR>            .Cells(0, 1).Value = "a"<BR>            .Cells(0, 2).Value = "c"<BR>            .Cells(0, 3).Value = "d"<BR>            .Cells(0, 0).RowSpan = 2<BR>        End With<BR>    End Sub<BR>End Class<BR>------------------------------------------<BR></P>
    <P> </P>
  • Replied 8 September 2017, 12:46 pm EST

    <P>Hello,</P>
    <P>This is planned for the middle of September.</P>
  • Replied 8 September 2017, 12:46 pm EST

    <P>Hello,</P>
    <P>Are you using the latest maintenance release? I tested this code and is exported to Excel without any exceptions.</P>
  • Replied 8 September 2017, 12:46 pm EST

    <P>Hi,</P>
    <P>Thank you for your reply.<BR>I'm using the version 03.00.2004, trial edition.<BR>(I download this trial edition the day before yesterday.)</P>
    <P>Is this the latest version or do you have any other latest version?</P>
    <P>I tried again and I got the exception message below...</P>
    <P>-------------------------------------------------------------<BR>See the end of this message for details on invoking <BR>just-in-time (JIT) debugging instead of this dialog box.</P>
    <P>************** Exception Text **************<BR>System.NullReferenceException: Object reference not set to an instance of an object.<BR>   at g.a(String A_0, Stream A_1, ExcelSaveFlags A_2, ExcelWarningList A_3)<BR>   at FarPoint.Win.Spread.FpSpread.SaveExcel(String fileName, ExcelSaveFlags saveFlags, ExcelWarningList warningList)<BR>   at FarPoint.Win.Spread.FpSpread.SaveExcel(String fileName, ExcelSaveFlags saveFlags)<BR>   at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in D:\My Documents\Visual Studio 2005\Projects\SpreadSaveExcel\SpreadSaveExcel\Form1.vb:line 9<BR>   at System.Windows.Forms.Control.OnClick(EventArgs e)<BR>   at System.Windows.Forms.Button.OnClick(EventArgs e)<BR>   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)<BR>   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<BR>   at System.Windows.Forms.Control.WndProc(Message& m)<BR>   at System.Windows.Forms.ButtonBase.WndProc(Message& m)<BR>   at System.Windows.Forms.Button.WndProc(Message& m)<BR>   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<BR>   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<BR>   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</P>
    <P><BR>************** Loaded Assemblies **************<BR>mscorlib<BR>    Assembly Version: 2.0.0.0<BR>    Win32 Version: 2.0.50727.832 (QFE.050727-8300)<BR>    CodeBase: <A>file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll</A><BR>----------------------------------------<BR>SpreadSaveExcel<BR>    Assembly Version: 1.0.0.0<BR>    Win32 Version: 1.0.0.0<BR>    CodeBase: <A>file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/SpreadSaveExcel.exe</A><BR>----------------------------------------<BR>Microsoft.VisualBasic<BR>    Assembly Version: 8.0.0.0<BR>    Win32 Version: 8.0.50727.42 (RTM.050727-4200)<BR>    CodeBase: <A>file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll</A><BR>----------------------------------------<BR>System<BR>    Assembly Version: 2.0.0.0<BR>    Win32 Version: 2.0.50727.832 (QFE.050727-8300)<BR>    CodeBase: <A>file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll</A><BR>----------------------------------------<BR>System.Windows.Forms<BR>    Assembly Version: 2.0.0.0<BR>    Win32 Version: 2.0.50727.832 (QFE.050727-8300)<BR>    CodeBase: <A>file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll</A><BR>----------------------------------------<BR>System.Drawing<BR>    Assembly Version: 2.0.0.0<BR>    Win32 Version: 2.0.50727.832 (QFE.050727-8300)<BR>    CodeBase: <A>file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll</A><BR>----------------------------------------<BR>System.Runtime.Remoting<BR>    Assembly Version: 2.0.0.0<BR>    Win32 Version: 2.0.50727.832 (QFE.050727-8300)<BR>    CodeBase: <A>file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll</A><BR>----------------------------------------<BR>FarPoint.Win.Spread<BR>    Assembly Version: 3.0.2004.2005<BR>    Win32 Version: 3.0.2004.2005<BR>    CodeBase: <A>file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.Win.Spread.DLL</A><BR>----------------------------------------<BR>FarPoint.Win<BR>    Assembly Version: 3.0.2004.2005<BR>    Win32 Version: 3.0.2004.2005<BR>    CodeBase: <A>file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.Win.DLL</A><BR>----------------------------------------<BR>System.Xml<BR>    Assembly Version: 2.0.0.0<BR>    Win32 Version: 2.0.50727.832 (QFE.050727-8300)<BR>    CodeBase: <A>file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll</A><BR>----------------------------------------<BR>System.Data<BR>    Assembly Version: 2.0.0.0<BR>    Win32 Version: 2.0.50727.832 (QFE.050727-8300)<BR>    CodeBase: <A>file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll</A><BR>----------------------------------------<BR>FarPoint.Win.TextRenderer<BR>    Assembly Version: 2.5.2001.2005<BR>    Win32 Version: 2.5.2001.2005<BR>    CodeBase: <A>file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.Win.TextRenderer.DLL</A><BR>----------------------------------------<BR>FarPoint.CalcEngine<BR>    Assembly Version: 3.0.2008.2005<BR>    Win32 Version: 3.0.2008.2005<BR>    CodeBase: <A>file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.CalcEngine.DLL</A><BR>----------------------------------------<BR>FarPoint.Excel<BR>    Assembly Version: 3.0.2008.2005<BR>    Win32 Version: 3.0.2008.2005<BR>    CodeBase: <A>file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.Excel.DLL</A><BR>----------------------------------------<BR>FarPoint.PluginCalendar.WinForms<BR>    Assembly Version: 3.0.2004.2005<BR>    Win32 Version: 3.0.2004.2005<BR>    CodeBase: <A>file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.PluginCalendar.WinForms.DLL</A><BR>----------------------------------------</P>
    <P>************** JIT Debugging **************<BR>To enable just-in-time (JIT) debugging, the .config file for this<BR>application or computer (machine.config) must have the<BR>jitDebugging value set in the system.windows.forms section.<BR>The application must also be compiled with debugging<BR>enabled.</P>
    <P>For example:</P>
    <P><configuration><BR>    <system.windows.forms jitDebugging="true" /><BR></configuration></P>
    <P>When JIT debugging is enabled, any unhandled exception<BR>will be sent to the JIT debugger registered on the computer<BR>rather than be handled by this dialog box.<BR></P>
  • Replied 8 September 2017, 12:46 pm EST

    <P>Hello,</P>
    <P>I see on my test machine, I was not using the latest maintnance release. I now tested this with the latest maintenance release and see the issue. This has been reported as a bug (#20987) and will be fixed in the next maintenance release.</P>
  • Replied 8 September 2017, 12:46 pm EST

    <P>Hi,</P>
    <P>Thank you for your reply.<BR>I'm wondering when will be the next maintenance.<BR>Please let us know as soon as possible.</P>
  • Replied 8 September 2017, 12:46 pm EST

    <P>Hi,<BR>I'm waiting for the maintenance release that is planned for the middle of September.<BR>When will the maintenance release is updated?</P>
    <P> </P>
  • Replied 8 September 2017, 12:46 pm EST

    <P>Hello,</P>
    <P>The new maintenance release is going through QA and having bugs fixed right now. We are planning on a release of the maintenance next week.</P>
  • Replied 8 September 2017, 12:46 pm EST

    <P> </P>
    <P>In a similar way the following code crashes 'SaveExcel' if either /or of the 'span' lines are unremmed.</P>
    <P>This is similar to the problem in the original post (code contained 'columnspan')</P>
    <P>'span' is the problem (wasted all Friday pm figuring this out!)</P>
    <P>regards to all</P>
    <P>ml</P>
    <P>code starts -------------</P><FONT color=#0000ff size=2>
    <P>Public</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Class</FONT><FONT size=2> Form1</P></FONT><FONT color=#0000ff size=2>
    <P>Private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Sub</FONT><FONT size=2> Form1_Load(</FONT><FONT color=#0000ff size=2>ByVal</FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> System.Object, </FONT><FONT color=#0000ff size=2>ByVal</FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> System.EventArgs) </FONT><FONT color=#0000ff size=2>Handles</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>MyBase</FONT><FONT size=2>.Load</P>
    <P>FpSpread1.Sheets(0).Cells(1, 1).Text = </FONT><FONT color=#a31515 size=2>"One"</P></FONT><FONT size=2>
    <P>FpSpread1.Sheets(0).Cells(2, 1).Text = </FONT><FONT color=#a31515 size=2>"Two"</P></FONT><FONT size=2>
    <P>FpSpread1.Sheets(0).Cells(3, 1).Text = </FONT><FONT color=#a31515 size=2>"Three"</P></FONT><FONT color=#008000 size=2>
    <P>'FpSpread1.Sheets(0).AddSpanCell(1, 1, 1, 2)</P>
    <P>'FpSpread1.Sheets(0).Cells(1, 1).ColumnSpan = 2</P></FONT><FONT size=2>
    <P>FpSpread1.SaveExcel(</FONT><FONT color=#a31515 size=2>"c:\temp\test.xls"</FONT><FONT size=2>)</P></FONT><FONT color=#0000ff size=2>
    <P>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Sub</P>
    <P>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Class</P></FONT>
    <P> </P>
    <P> </P>
  • Replied 8 September 2017, 12:46 pm EST

    <P>Hello,</P>
    <P>Thank you for pointing this out. I tested this with the latest build we are currently testing, and this problem has been fixed. We should have this maintenance release available as soon as possible.</P>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels