473,657 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Applicati onClass oExcelApp = new Excel.Applicati onClass();
Object oMissing = System.Reflecti on.Missing.Valu e;
Excel.Workbook oWB = oExcelApp.Workb ooks.Open(sFile Name, oMissing,
oMissing,oMissi ng, oMissing,oMissi ng, oMissing, oMissing,
oMissing,oMissi ng,oMissing, oMissing, oMissing);
object oSaveFileName = REPOSITORY_PATH + System.Guid.New Guid().ToString () +
".txt";
oExcelApp.Activ eWorkbook.SaveA s(oSaveFileName ,
Excel.XlFileFor mat.xlCSVWindow s, oMissing, oMissing, oMissing,oMissi ng,
Excel.XlSaveAsA ccessMode.xlSha red, oMissing, oMissing, oMissing, oMissing);

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

When I change Excel.XlFileFor mat.xlCSVWindow s to
Excel.XlFileFor mat.xlWorkbookN ormal it works fine saving as an Excel file.

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

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

Similar topics

1
3057
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 workstation. I don't need examples of a Windows application where everything is local. I've tried KB306022 which doesn't work. I've included references to Microsoft.Office.Core and Microsoft Excel 11.0 Object Library. When I try to use the...
1
2713
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 other for the harddrive capacity and then spit out a price. I don't have access to any database or server side scripting so I think javascript is the best solution but I could be completely off. If anyone could help me out, I'd appreciate it a...
3
7029
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 into Access. I want to avoid creating a separate "Spec" for each file (there are over 180 files) and instead want to code my own dynamic importing rules. So far it's been going fine, except for one item...
4
2300
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 table is created then I need to fill the table with the data from that spreadsheet. I am using ASP.NET 2.0 and SQL 2000 for my database. What would be the best way to do this? Should I go Excel to XML or Excel to a Dataset?
3
2347
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 Excel sheet, but instead of being comma delimited, it will be delimited by spaces. Regarding the Word document, I can set rules for the field length myself, but my question is regarding the proper programming APIs to use. Can this be done via...
2
10344
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 to be working ok. I just don't know what I'm doing when I try to open a space delimited file and want to put the data into columns. I tried recording a macro in VBA and going from there, but then I got stuff saying "Name 'xlDelimited' is not...
1
3090
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
1218
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 that will open and save the file in Excel but in needs to be delimited. What I have is below. How can I get this into Excel format? Thanks for any help.
15
17373
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 TestAddress1 111-2222 lets say the number field is 10 characters long, there is a space and Name field is 15 characters long, there is a space, address can be 25 characters long, there is a space and phone is 10 characters long I want to...
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8845
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8743
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6177
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.