Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default System.Runtime.InteropServices.COMException (0x800A03EC)

hi,
One of my client got error while Exporting data from datatable to excel

sheet.He got error Like
this"System.Runtime.InteropServices.COMException (0x800A03EC): This
command is unavailable because the license to use this application has
expired." He told me that his linense was not expired and also he try
same after installed again office

I was used Com Component for exporting data to excel :microsoft office
9.0 through add refereance -com


and function from where Actually Excel Export is Like this


======
Public Sub Export2Excel(ByVal dt As DataTable, ByVal strPath As String)

Dim objXL As Excel.Application
Dim objWBS As Excel.Workbooks
Dim objWB As Excel.Workbook
Dim objWS As Excel.Worksheet
Dim colIndex As Integer
Dim rowIndex As Integer
Dim col As DataColumn
Dim mRow As DataRow
're-set pb so it displays correctly if called again
Try
If File.Exists(strPath) Then
File.Delete(strPath)
End If
Try
'get a running instance of Excel - this minimizes the
number of instances of Excel in memory!
objXL = CType(GetObject(, "Excel.Application"),
Excel.Application)
Catch ex As Exception
'create a new instance of Excel if there isn't one
running.
objXL = New Excel.Application
End Try
objWBS = objXL.Workbooks
objWB = objWBS.Add
objWS = CType(objWB.Worksheets(1), Excel.Worksheet)
'write column headers to Excel's first row from the dt.
For Each col In dt.Columns
colIndex += 1
objWS.Cells(1, colIndex) = col.ColumnName
Next col
'Bold and widen all the column headings
objWS.Range("A1:X1").Font.Bold = True
objWS.Columns.ColumnWidth = 10.5
'make some columns wider than the others
objWS.Range("A1:Q1").Font.Bold = True
objWS.Range("A:A").ColumnWidth = 17
objWS.Range("C:C").ColumnWidth = 39
objWS.Range("E:F").ColumnWidth = 20
objWS.Range("L:O").ColumnWidth = 20
objWS.Range("T:T").ColumnWidth = 13
'rename the sheet to the file name w/o extension
objWS.Name = Path.GetFileName(strPath)
'write data starting on row with column headers because the

first step is to increment to the next row.
rowIndex = 1
For Each mRow In dt.Rows


rowIndex += 1
colIndex = 0
For Each col In dt.Columns
colIndex += 1
'force to text data by adding a leading apostrophe
objWS.Cells(rowIndex, colIndex) =
mRow(col.ColumnName).ToString
Next col
Next mRow
'make all rows same height
objWS.Range("A1:A" & CStr(dt.Rows.Count)).RowHeight = 12.75

objWB.SaveAs(strPath)
objWB.Close()


System.Runtime.InteropServices.Marshal.ReleaseComO bject(objWS)


System.Runtime.InteropServices.Marshal.ReleaseComO bject(objWB)


System.Runtime.InteropServices.Marshal.ReleaseComO bject(objWBS)
objXL.Quit()


System.Runtime.InteropServices.Marshal.ReleaseComO bject(objXL)
Catch exc As Exception
Throw
Finally
objWS = Nothing
objWB = Nothing
objWBS = Nothing
objXL = Nothing
End Try
End Sub
=====

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart.Export throws COMException (0x800A03EC) Benchmark Developmer Charts and Charting in Excel 0 August 30th 07 05:40 PM
System.Runtime.InteropServices.COMException (0x80020005) in excel 2k7, but worked well in 2k3 dotNeter Excel Programming 0 November 15th 06 07:15 AM
I get COMException while exporting chart on IIS 6.0. asp newbie Charts and Charting in Excel 1 May 16th 06 08:27 AM
Excel SaveCopyAs COMException 0x800A03EC Jim McLeod Excel Programming 0 May 25th 04 12:26 AM
Chart.Export throws COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC. Steven Excel Programming 1 November 5th 03 06:59 PM


All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"