Solved

how to deploy excel app to server without MS office

Posted on 2009-05-11
4
802 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

615 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