Hi,

using Interop is not best way to work with Excel in .NET. You can try using GemBox .NET Excel component which is free for commercial use (limit is 150 rows).

Here is a list of reasons why GemBox.Spreadsheet is better then Excel Interop and Excel Automation

By on 7/14/2009 7:07 AM ()

Are you trying to do this in F# (since this is an F# forum)?

Try using this library:

[link:www.codeproject.com]

I have not tried it but it may work for you if you are writing this in F# or C#. Note that you will have to create a datatable first.

By on 12/8/2008 4:41 PM ()

Yes, I'm trying to do this in F#. I was using the approach in F# for Scientists, and getting nowhere. I think maybe I need the Visual Studio Professional that includes the Visual Studio Tools for Office. Can anyone at Microsoft tell me if I'm right or wrong? At present I'm using the Visual Studio free version.

I'd like a lightweight approach rather than a whole class library.

Thanks.

Bob

By on 12/8/2008 6:29 PM ()

you can't use F# with express edition

you can try Sharpdevelopp 3.0 with F# project

add reference to <i>Microsoft.Office.Interop.<i><i>Excel<i> (you find it COM tab) see below for an example (in excel 2003) <i>#light <i> <i>module I<i><i>nteropExcel2003<i> <i>open <i><i>Microsoft.Office.Interop.Excel <i> <i>let <i><i>u=System.Reflection.Missing.Value <i><i>// for missing values<i> <i>l<i><i>et <i><i>app=new Microsoft.Office.Interop.Excel.<B>ApplicationClass</B><i><i>(Visible=true)<i> <i>app<i><i>.ScreenUpdating <- false<i> <i>// add a new workbook<i> <i>let <i><i>wb=app.Workbooks.<B>Add</B><i><i>(XlWBATemplate.xlWBATWorksheet)<i> <i>// note the cast<i> <i>let <i><i>ws=wb.Worksheets.[1] :?> Worksheet<i> <i>// write in a cell, box is optionnal<i> <i>ws<i><i>.Cells.<B>Item</B><i><i>(1,1) <- box "hello world"<i> <i>// write in a range<i> <i>let <i><i>m,n = 100,200<i> <i>let <i><i>hello_worlds=Array2.init m <B>n </B><i><i>(fun i j -> sprintf "hello world (%i, %i)" i j)<i> <i>let <i><i>r=ws.<B>get_Range</B><i><i>(ws.Cells.<B>Item</B><i><i>(2,2),ws.Cells.<B>Item</B><i><i>(2+m-1,2+n-1))<i> <i>// use Value2 not Value<i> <i>r<i><i>.Value2 <- <i><i>box hello_worlds<i> <i>app<i><i>.ScreenUpdating <- true<i>

By on 12/12/2008 4:58 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper