Problem about SaveExcel

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

  • Posted 8 September 2017, 12:46 pm EST

    Hi all,


    I'm using the Spread for Windows Forms v3 for VS2005.
    Now, I have a trouble with SaveExcel Command.


    I want to export excel from the spread that uses ColumnSpan and RowSpan.


    But, when i use SaveExcel Command to export data, i got NullReference Exception.
    I have tried some Options(SaveFlags) and I found that I can export data with using the DataOnly.


    How can i export data from spread that used ColumnSpan and RowSpan?


    OK -- FpSpread1.SaveExcel(sFileName, FarPoint.Excel.ExcelSaveFlags.DataOnly)
    NG -- FpSpread1.SaveExcel(sFileName, FarPoint.Excel.ExcelSaveFlags.SaveBothCustomRowAndColumnHeaders)


    My sample source is here...
    ------------------------------------------
    Public Class Form1


        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim sFileName As String
            Dim fbd As New FolderBrowserDialog
            If fbd.ShowDialog() = Windows.Forms.DialogResult.OK Then


                sFileName = fbd.SelectedPath & "\" & "a.xls"
                FpSpread1.SaveExcel(sFileName, FarPoint.Excel.ExcelSaveFlags.SaveBothCustomRowAndColumnHeaders)
            End If


        End Sub


        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            With FpSpread1.ActiveSheet
                .ColumnHeader.Cells(0, 0).Value = "aaa"
                .ColumnHeader.Cells(0, 0).ColumnSpan = 2
                .Cells(0, 0).Value = "a"
                .Cells(0, 1).Value = "a"
                .Cells(0, 2).Value = "c"
                .Cells(0, 3).Value = "d"
                .Cells(0, 0).RowSpan = 2
            End With
        End Sub
    End Class
    ------------------------------------------


     

  • Replied 8 September 2017, 12:46 pm EST

    Hello,


    This is planned for the middle of September.

  • Replied 8 September 2017, 12:46 pm EST

    Hello,


    Are you using the latest maintenance release? I tested this code and is exported to Excel without any exceptions.

  • Replied 8 September 2017, 12:46 pm EST

    Hi,


    Thank you for your reply.
    I'm using the version 03.00.2004, trial edition.
    (I download this trial edition the day before yesterday.)


    Is this the latest version or do you have any other latest version?


    I tried again and I got the exception message below...


    -------------------------------------------------------------
    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.


    ************** Exception Text **************
    System.NullReferenceException: Object reference not set to an instance of an object.
       at g.a(String A_0, Stream A_1, ExcelSaveFlags A_2, ExcelWarningList A_3)
       at FarPoint.Win.Spread.FpSpread.SaveExcel(String fileName, ExcelSaveFlags saveFlags, ExcelWarningList warningList)
       at FarPoint.Win.Spread.FpSpread.SaveExcel(String fileName, ExcelSaveFlags saveFlags)
       at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in D:\My Documents\Visual Studio 2005\Projects\SpreadSaveExcel\SpreadSaveExcel\Form1.vb:line 9
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.832 (QFE.050727-8300)
        CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    SpreadSaveExcel
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/SpreadSaveExcel.exe
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 8.0.0.0
        Win32 Version: 8.0.50727.42 (RTM.050727-4200)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.832 (QFE.050727-8300)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.832 (QFE.050727-8300)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.832 (QFE.050727-8300)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Runtime.Remoting
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.832 (QFE.050727-8300)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    FarPoint.Win.Spread
        Assembly Version: 3.0.2004.2005
        Win32 Version: 3.0.2004.2005
        CodeBase: file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.Win.Spread.DLL
    ----------------------------------------
    FarPoint.Win
        Assembly Version: 3.0.2004.2005
        Win32 Version: 3.0.2004.2005
        CodeBase: file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.Win.DLL
    ----------------------------------------
    System.Xml
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.832 (QFE.050727-8300)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Data
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.832 (QFE.050727-8300)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    FarPoint.Win.TextRenderer
        Assembly Version: 2.5.2001.2005
        Win32 Version: 2.5.2001.2005
        CodeBase: file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.Win.TextRenderer.DLL
    ----------------------------------------
    FarPoint.CalcEngine
        Assembly Version: 3.0.2008.2005
        Win32 Version: 3.0.2008.2005
        CodeBase: file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.CalcEngine.DLL
    ----------------------------------------
    FarPoint.Excel
        Assembly Version: 3.0.2008.2005
        Win32 Version: 3.0.2008.2005
        CodeBase: file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.Excel.DLL
    ----------------------------------------
    FarPoint.PluginCalendar.WinForms
        Assembly Version: 3.0.2004.2005
        Win32 Version: 3.0.2004.2005
        CodeBase: file:///C:/Documents%20and%20Settings/CES-TEST/Desktop/Debug%20on%20yamada/FarPoint.PluginCalendar.WinForms.DLL
    ----------------------------------------


    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.


    For example:



       


    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

  • Replied 8 September 2017, 12:46 pm EST

    Hello,


    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.

  • Replied 8 September 2017, 12:46 pm EST

    Hi,


    Thank you for your reply.
    I'm wondering when will be the next maintenance.
    Please let us know as soon as possible.

  • Replied 8 September 2017, 12:46 pm EST

    Hi,
    I'm waiting for the maintenance release that is planned for the middle of September.
    When will the maintenance release is updated?


     

  • Replied 8 September 2017, 12:46 pm EST

    Hello,


    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.

  • Replied 8 September 2017, 12:46 pm EST

     


    In a similar way the following code crashes 'SaveExcel' if either /or of the 'span' lines are unremmed.


    This is similar to the problem in the original post (code contained 'columnspan')


    'span' is the problem (wasted all Friday pm figuring this out!)


    regards to all


    ml


    code starts -------------


    Public Class Form1


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    FpSpread1.Sheets(0).Cells(1, 1).Text = "One"


    FpSpread1.Sheets(0).Cells(2, 1).Text = "Two"


    FpSpread1.Sheets(0).Cells(3, 1).Text = "Three"


    'FpSpread1.Sheets(0).AddSpanCell(1, 1, 1, 2)


    'FpSpread1.Sheets(0).Cells(1, 1).ColumnSpan = 2


    FpSpread1.SaveExcel("c:\temp\test.xls")


    End Sub


    End Class


     


     

  • Replied 8 September 2017, 12:46 pm EST

    Hello,


    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.

Need extra support?

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

Learn More

Forum Channels