locked
Export to multiple excel sheets RRS feed

  • Question

  • User1094706579 posted

    Hey all Im new to asp.net, I am trying to create an application that would allow my users to export information to multiple EXISTING excel sheets. So far I have been sucessful in exporting to one sheet but I am unsure how to go about exporting it to multiple excel sheets within the same workbook, does anyone have any ideas or can you point me in the right direction on how to do this! Any help is always much appreciated

    Thank you

     

    Here is the code

     

    Imports System.IO
    Imports Microsoft.Office.Interop.Excel
    Imports System.Runtime.InteropServices.Marshal
    Imports Microsoft.Office.Interop

     

    Partial Class Export2Excel
        Inherits System.Web.UI.Page


        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

            Try
                Dim ExcelApplication As Excel.Application
                ExcelApplication = CreateObject("Excel.Application")

                Dim ExcelWorkBook As Excel.Workbook
                ExcelWorkBook = ExcelApplication.Workbooks.Open("C:\ Files\10021 - 10037.xls")

                Dim ExcelWorkSheet As Excel.Worksheet
                ExcelWorkSheet = ExcelWorkBook.Worksheets(1)
                ExcelWorkSheet.Cells(42, 1) = TextBox1.Text

            

                ExcelWorkBook.Save()
                ExcelWorkBook.Close()
                ExcelApplication.Quit()
            Catch ex As Exception
                Response.Write("Failure has occured")

            End Try
     

        End Sub

    End Class

     

    Wednesday, December 9, 2009 10:45 AM

Answers

All replies