I would like to export the Data from FpSpread1 to excel

Posted by: xanhnhnn280683 on 8 September 2017, 2:27 pm EST

  • Posted 8 September 2017, 2:27 pm EST

    welcome you !!!!

    I have 2 forms, form1 is main form  have button1,form2 is sub form have button2 and FpSpread1, when I click button2 it export the results is true.

    When I click button1 it export the results is false. Therefore, How do you write to click button1 export the results is true?

    My code follow

    Private Sub  Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Form2.LUUTAPTIN()
        End Sub

    Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            LUUTAPTIN()
        End Sub

    Public Sub LUUTAPTIN()
            Dim s As System.IO.Stream
            SaveFileDialog1.Title = "Luu t?p tin"
            SaveFileDialog1.Filter = "Excel 97 - 2003 (*.xls)|*.xls"
            SaveFileDialog1.FilterIndex = 2
            SaveFileDialog1.RestoreDirectory = True
            If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
                s = SaveFileDialog1.OpenFile
                If Not (s Is Nothing) Then
                    Me.FpSpread1.SaveExcel(s, FarPoint.Excel.ExcelSaveFlags.NoFlagsSet)
                End If
            End If
        End Sub

    I

  • Replied 8 September 2017, 2:27 pm EST

    Hello,


    Your code is working for me. You will need to make sure you initialize the Spread on the second form correctly. Following your steps will not have the Form_Load event on the second form fired. So if your code to initialze the spreadsheet is in this event, you will get an empty Spread. Also, you may want to close your stream after you are done with it.

  • Replied 8 September 2017, 2:27 pm EST

    welcome you!!!

     I have used button2  to  convert controls FpSpread data into a format file Excel 2003. I use Excel 2003 to format without, would you help me on file formats Excel 2003. Thanks

    Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
           Dim s As System.IO.Stream

            SaveFileDialog1.Title = "Luu t?p tin"

            SaveFileDialog1.Filter = "Excel 97 - 2003 (*.xls)|*.xls"

            SaveFileDialog1.FilterIndex = 2

            SaveFileDialog1.RestoreDirectory = True

            If SaveFileDialog1.ShowDialog() = DialogResult.OK Then

                s = SaveFileDialog1.OpenFile

                If Not (s Is Nothing) Then

                    Me.FpSpread1.SaveExcel(s, FarPoint.Excel.ExcelSaveFlags.NoFlagsSet)

                End If

            End If
        End Sub


           
       

     

  • Replied 8 September 2017, 2:27 pm EST

    Hello,


    Could you give us some more information about the issue you are having? In the first message, button 2 was working and it was button 1 that was not. Now, you have moved the code from your Sub for saving the Spread to Excel into the ButtonClick event directly. This should work the same as you had it. Is the problem now that you want spread formatting exported to Excel with the data? Could you post a small zipped project showing the issue you are seeing for us to debug?

Need extra support?

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

Learn More

Forum Channels