|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Export array from vb.net to excelCan anyone help me. I wish to export an array from vb.net to excel
ranges. This will happen for multiple files. The ranges names will not be start and end in the same cells on all files. How do i do this? One way to do this is to write a subroutine in your Excel spreadsheet that
takes either an object or variant as a parameter, convert the object to a string array and input your values from the array into the range that you wish. I've done this in VB6 but not .NET. It looks like it should work in ..Net as well. Just include a reference to the Microsoft Excel Object library (whatever version that's on your machine and the target machines). Then do something like this: Dim o As Excel.Application Dim xsheet As Workbook Dim myArray(5) As String ' is Excel already open? o = GetObject(, "Excel.Application") ' if not, open it If o Is Nothing Then o = CreateObject("Excel.Application") End If For i As Integer = 0 To myArray.GetUpperBound(0) myArray(i) = i.ToString() Next xsheet = o.Workbooks.Open(FileName:="somefilenameandpath") xsheet.Application.Visible = True ' run the subroutine you want xsheet.Application.Run("RoutineName_FileRange", myArray) HTH Steve <michealm***@bigpond.com> wrote in message Show quoteHide quote news:1159415945.889864.269810@h48g2000cwc.googlegroups.com... > Can anyone help me. I wish to export an array from vb.net to excel > ranges. This will happen for multiple files. The ranges names will not > be start and end in the same cells on all files. How do i do this? >
http://www.kjmsolutions.com/datasetarray.htm
michealm***@bigpond.com wrote: Show quoteHide quote > Can anyone help me. I wish to export an array from vb.net to excel > ranges. This will happen for multiple files. The ranges names will not > be start and end in the same cells on all files. How do i do this? Thanks for the replies but I will not be haing a reference to Excel at
all. Hi Micheal
If you're not having any references to Excel then I don't imagine you're going to be able to do this as ranges and names are Excel specific so unless you are familiar with the Excel file format and are comfortable creating files in this format (or you're using a version of Excel that uses an XML file format) then you're left with the choice of buying/using an Excel component (Aspose for example) or referencing Excel. HTH Martin michealm***@bigpond.com wrote: Show quoteHide quote > Thanks for the replies but I will not be haing a reference to Excel at > all.
http://www.kjmsolutions.com/datasetarray.htm
michealm***@bigpond.com wrote: Show quoteHide quote > Can anyone help me. I wish to export an array from vb.net to excel > ranges. This will happen for multiple files. The ranges names will not > be start and end in the same cells on all files. How do i do this?
Handle Worked - can someone please double check
Bug in Datagrids XML to save some settings Multiple child forms - updating the right one Finding a control on a form with a text reference filter dataTable/datagridview to show top 1 row for duplicate IDs? File converting/sending help Date as Null Are you a C# Developer in Buckinghamshire? DirectX and Sound |
|||||||||||||||||||||||