Solved Create excel sheet without Excel

Posted on 2011-04-29
Last Modified: 2012-06-27

I am looking for a way to reading and writing to excel sheets without the requirement of a specific Excel version being installed on the client PC.  Even though the PC will most likely have some version Excel installed, my company isn't locked down to one particular version.  That has caused me problems in the past.

To read excel sheets i have been using ODBC and that works fine, but i would like to come up with some standard way of being able to create excel sheets and not have to depend on the PC's installed version.

I have seen a few 3rd part components that would seem to be what i am looking for.  Does anyone have any experience with these components or another method?  To give a little scope, i don't need to be doing anything too complex with the sheets.  Just reading, writting, and some basic formatting..

Any suggestions on components (you have actual experience with) or alternative methods of accomplishing my goal are appreciated.
Question by:MRS
    LVL 83

    Expert Comment

    LVL 3

    Accepted Solution


    Author Comment

    Thank you both for the suggestions...


    I have looked at the Apose Suite before, but they are out of my price range.  at $6000 per developer license it would be cheaper to but everyone in the company office..

    Have you had any experience with the GemBox component.  The price seems a little more reasonable if it works as well as it says it does.
    LVL 2

    Expert Comment

    I like using the Excel COM object.  It's free with the application and has been around for several versions.  The syntax may change a bit from version to version, but if you're truly working on basic functionality, that shouldn't impact you.  I'll include a basic VBScript version of interacting with the object.  There is a TON of documentation on it, and you can include a reference to it from Visual Studio as well.  The intellisense there should help you figure out the specifics for your application.

    The object model is here.

    'Set output file name
    Dim xls
    xls = xlFilePath & "\" & xlFileName
    'Create the excel application object
    Dim Excel
    Set Excel = CreateObject("Excel.Application")
    Excel.DisplayAlerts = False
    'Open the xls file if it exists, or create a new file if it does not exist
    Dim wb
    On Error Resume Next
    Set wb = Excel.Workbooks.Open(xls)
    If err.Number = 1004 Then
    	Set wb = Excel.Workbooks.Add()
    End If
    If err.Number <> 0 Then
    	Exit Sub
    End If
    On Error GoTo 0
    'Create excel worksheet and cell objects
    Dim ws, c, pg
    Set ws = wb.Sheets(1)
    Set c = ws.Cells
    'Add values to the spreadsheet
    c(1,1).value = "TESTING1"
    c(1,2).value = "TESTING2"
    c(1,3).value = "TESTING3"
    c(1,4).value = "TESTING4"
    c(1,5).value = "TESTING5"
    'Save the xls file
    On Error Resume Next
    'Save the xls file
    If err.Number = 1004 Then
    	Set c = Nothing
    	Set ws = Nothing
    	Set wb = Nothing
    	Set Excel = Nothing
    	Exit Sub	
    End If
    On Error GoTo 0
    'Close the xls file

    Open in new window


    Author Comment


    Your example is what I have done in the past.  I am trying to get away from untyped objects like that.

    I have decided to go with the Gembox component.  The price is fair and the component seems do to everything i need.  Thank you all for your input.


    Author Closing Comment

    I went with the GemBox component that was linked at the bottom of the forum page you linked.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    Outlook Free & Paid Tools
    This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
    The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now