![]() |
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. |
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. |
All times are GMT +1. The time now is 10:47 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com