473,408 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Saving Excel file as text or comma delimited from C#

dd
I am kind of puzzled with this problem.
I am trying to open an xls file from C# and then save it as text or comma
delimited. Here is the code:
Excel.ApplicationClass oExcelApp = new Excel.ApplicationClass();
Object oMissing = System.Reflection.Missing.Value;
Excel.Workbook oWB = oExcelApp.Workbooks.Open(sFileName, oMissing,
oMissing,oMissing, oMissing,oMissing, oMissing, oMissing,
oMissing,oMissing,oMissing, oMissing, oMissing);
object oSaveFileName = REPOSITORY_PATH + System.Guid.NewGuid().ToString() +
".txt";
oExcelApp.ActiveWorkbook.SaveAs(oSaveFileName,
Excel.XlFileFormat.xlCSVWindows, oMissing, oMissing, oMissing,oMissing,
Excel.XlSaveAsAccessMode.xlShared, oMissing, oMissing, oMissing, oMissing);

I am getting an exception: "An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in Test1.exe
Additional information: Exception from HRESULT: 0x800A03EC."

When I change Excel.XlFileFormat.xlCSVWindows to
Excel.XlFileFormat.xlWorkbookNormal it works fine saving as an Excel file.

Can please anybody help?
Nov 15 '05 #1
0 6353

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: frankvfox | last post by:
I need a code sample using VB ASP.Net 2003 which exports a tab delimited text file resident on the server into an Excel spreadsheet which will be saved through the browser to the client's local...
1
by: bryanilton | last post by:
Hi guys, I hope that one of you gurus can help me out here. Basically what I'd like to do is be able to price harddrives. I'd like to have two drop-down boxes. One for the manufacturer and the...
3
by: Ben | last post by:
Hi all - I am having a bit of trouble and thought maybe someone in this group could shed some light. Here's the skinny... I am creating an automated process to import a bunch of text files...
4
by: washoetech | last post by:
Hello, I am working on a project where I need to be able to grab the data from an Excel spreadsheet and create a new table in my database based on the columns in the spreadsheet. After the...
3
by: herman404 | last post by:
Hi everyone, I have data coming to me in the form of Word and Excel files, and I need to place this data into a SQL Server database. The Word file will be coming in text which is similiar to an...
2
by: Jacob.Bruxer | last post by:
Hi everyone, I'm having trouble opening space delimited textfiles in Excel from Visual Basic.net. I'm able to control, open and modify Excel files from Visual Basic, so my Excel reference seems...
1
by: Quentin | last post by:
I want to take a comma delimited text file and export it to excel format, using the comma as the delimiter. Any help on this would be great, thank you.
0
by: Hoop | last post by:
Hi, I have a VB app that I am trying to open a text file where the data is comma seperated. I would like to save that file so that the user can open it in Excel rows and columns. I have code...
15
by: pakerly | last post by:
How would i do this, convert a test file to excel? Lets say my text file has fields like this: NUMBER NAME ADDRESS PHONE 11002 Test1 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.