Solved

how to deploy excel app to server without MS office

Posted on 2009-05-11
4
801 Views
Last Modified: 2012-06-22
I have written a windows service in vb.net to create Excel reports (lot of formatting, calculations ect.,)
The program works file in my PC but not in a server. My PC had been installed Excel 2003, but the server has no any MS Office.

To install my application in the server I generated a setup.exe and msi file and copied them to a folder in the server, and run setup.exe. After running the setup I saw that three dll were added in that folder:

Microsoft.Office.Interop.Excel.dll, Microsoft.Vbe.Interop.Excel.dll, and Office.dll.

Those three dlls should contain all the functions that are necessary for reading data from Excel file. However, the error was generated as soon as the code reaches the following three lines:

Dim myExcel As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim wBook As Microsoft.Office.Interop.Excel.Workbook
Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet

The error message reads

Unhandled Exceptionj: System.Runtime.InteropServices.COMException <Ox80040154>: Retrieving the COM Class factory for Component with CLSID <&> failed due to the following error: 80040154.

Any help would be greatly appreciated.
0
Comment
Question by:jyothsna1803
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Assisted Solution

by:ChloesDad
ChloesDad earned 200 total points
ID: 24359286
I had this problem as well, and the simple answer is that you can't.

If you want to run this code on the server then you have to purchase a copy of excel for the server. Microsoft wouldn't allow you to freely distribute Excel, as its their copywrite etc.
0
 

Author Comment

by:jyothsna1803
ID: 24364384
ChloesDad, Thanks for your quick response. Does it mean Microsoft is charing extra bucks for interopServices for each server? how funny it is..If you have any other workble solutions please advice me..
0
 
LVL 15

Assisted Solution

by:ChloesDad
ChloesDad earned 200 total points
ID: 24365852
The interop services allow you to access the objects in vb, but you need to have the actual program to run code.

We changed our code to write out a comma separated file that can be imported into excel, but this only allows text not formulae to be included in the file
0
 

Accepted Solution

by:
jyothsna1803 earned 0 total points
ID: 24981045
Without using excel object i have coded and seems it is working fine, But i don't have any formatting options in my style.

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.IO
Public Class ExcelWriter
    Private stream As Stream
    Private writer As BinaryWriter

    Private clBegin As UShort() = {&H809, 8, 0, &H10, 0, 0}
    Private clEnd As UShort() = {&HA, 0}


    Private Sub WriteUshortArray(ByVal value As UShort())
        For i As Integer = 0 To value.Length - 1
            writer.Write(value(i))
        Next
    End Sub

    ''' <summary>
    ''' Initializes a new instance of the <see cref="ExcelWriter"/> class.
    ''' </summary>
    ''' <param name="stream">The stream.</param>
    Public Sub New(ByVal stream As Stream)
        Me.stream = stream
        writer = New BinaryWriter(stream)
    End Sub

    ''' <summary>
    ''' Writes the text cell value.
    ''' </summary>
    ''' <param name="rownum">The row.</param>
    ''' <param name="col">The col.</param>
    ''' <param name="value">The string value.</param>
    Public Sub WriteCell(ByRef rownum As Integer, ByVal col As Integer, ByVal value As String)
        Dim clData As UShort() = {&H204, 0, 0, 0, 0, 0}
        Dim iLen As Integer = value.Length
        Dim plainText As Byte() = Encoding.ASCII.GetBytes(value)
        clData(1) = CUShort((8 + iLen))
        clData(2) = CUShort(rownum)
        clData(3) = CUShort(col)
        clData(5) = CUShort(iLen)
        WriteUshortArray(clData)
        writer.Write(plainText)

    End Sub

    ''' <summary>
    ''' Writes the integer cell value.
    ''' </summary>
    ''' <param name="row">The row number.</param>
    ''' <param name="col">The column number.</param>
    ''' <param name="value">The value.</param>
    Public Sub WriteCell(ByVal row As Integer, ByVal col As Integer, ByVal value As Integer)
        Dim clData As UShort() = {&H27E, 10, 0, 0, 0}
        clData(2) = CUShort(row)
        clData(3) = CUShort(col)
        WriteUshortArray(clData)
        Dim iValue As Integer = (value << 2) Or 2
        writer.Write(iValue)
    End Sub

    ''' <summary>
    ''' Writes the double cell value.
    ''' </summary>
    ''' <param name="row">The row number.</param>
    ''' <param name="col">The column number.</param>
    ''' <param name="value">The value.</param>
    Public Sub WriteCell(ByVal row As Integer, ByVal col As Integer, ByVal value As Double)
        Dim clData As UShort() = {&H203, 14, 0, 0, 0}
        clData(2) = CUShort(row)
        clData(3) = CUShort(col)
        WriteUshortArray(clData)
        writer.Write(value)

    End Sub

    ''' <summary>
    ''' Writes the empty cell.
    ''' </summary>
    ''' <param name="row">The row number.</param>
    ''' <param name="col">The column number.</param>
    Public Sub WriteCell(ByVal row As Integer, ByVal col As Integer)
        Dim clData As UShort() = {&H201, 6, 0, 0, &H17}
        clData(2) = CUShort(row)
        clData(3) = CUShort(col)
        WriteUshortArray(clData)
    End Sub

    ''' <summary>
    ''' Must be called once for creating XLS file header
    ''' </summary>
    Public Sub BeginWrite()
        WriteUshortArray(clBegin)
    End Sub

    ''' <summary>
    ''' Ends the writing operation, but do not close the stream
    ''' </summary>
    Public Sub EndWrite()
        WriteUshortArray(clEnd)
        writer.Flush()
    End Sub
End Class
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

729 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