Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Excel automation

Hi,

I am facing a peculiar problem with Excel Automation. I have a winform where
in I display some data in OWC axSpreadsheet. Next I export this data to an
..xls file. When I try to open (through OleDb) and read this file, I get an
error -

"External table is not in the expected format." However, if I have the file
open in Excel, I am able to read it through code.

However the same piece of code works for some files without having them
opened in Excel. What am I missing out here? Please suggest.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel automation

Hi..

Same Problem we faced.. but Problem is here..
In your data , somewhere data like 2032-32-32 it's as a string in Database
and when u import data from DataBase to Excel and you given a
numberformat="@" yet it's automatically count that cell datatype as a
DataTime..

and Your Excel sheet is not a Microsoft Workbook Sheet(.Xls) but it's XML
SpreadSheet (.Xls) cause you are using OWC. after taking that file on your PC
, open that file as XML.. and see Format of that file .. It's Look like
this.. <.. ns:DataTime2032-32-32</.. so you have to change that fromat from
DateTime to string.

I m suggesting one solution.. may be others..

After
xlsheet.Export(strSourceFileName,
OWC.SheetExportActionEnum.ssExportActionNone)

Do This....
Dim XLSContent As String
XLSContent = System.IO.File.ReadAllText(strSourceFileName)
XLSContent = XLSContent.Replace("ss:Type=""DateTime""", "ss:Type=""String""")
System.IO.File.WriteAllText(strSourceFileName, XLSContent)

Now, you are thinking i told you look like ns:DateTime than why i write
ss:Type.. cause when Conversion occure at that time it's format is ss:Type..

Try this one.. Best Luck
"Kaustav" wrote:

Hi,

I am facing a peculiar problem with Excel Automation. I have a winform where
in I display some data in OWC axSpreadsheet. Next I export this data to an
.xls file. When I try to open (through OleDb) and read this file, I get an
error -

"External table is not in the expected format." However, if I have the file
open in Excel, I am able to read it through code.

However the same piece of code works for some files without having them
opened in Excel. What am I missing out here? Please suggest.

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
Excel Automation using .NET Suman Excel Programming 1 April 7th 05 12:49 PM
Excel automation in VB.net KC[_4_] Excel Programming 1 September 29th 04 03:36 PM
Excel automation in MFC charian Excel Programming 0 July 20th 04 03:45 AM
Excel automation in a VB app [email protected] Excel Programming 1 January 12th 04 07:59 PM
Vb.net - excel 97 automation michael Excel Programming 0 August 14th 03 06:16 PM


All times are GMT +1. The time now is 02:13 AM.

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

About Us

"It's about Microsoft Excel"