473,805 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert a .txt file extension to a .xls file extension?

Using VB.NET, How do I convert a .txt file extension to a .xls file
extension? The text file is already created and saved in a folder on the
server.
Thanks
Steven
Aug 24 '06 #1
3 4260
Steve,

System.IO.File. Move("c:\test.t xt", "c:\test.xl s")

Regards,
Augustin
http://augustinprasanna.blogspot.com

"Steve" wrote:
Using VB.NET, How do I convert a .txt file extension to a .xls file
extension? The text file is already created and saved in a folder on the
server.
Thanks
Steven
Aug 25 '06 #2
Hi,

Augustin Prasanna wrote:
Steve,

System.IO.File. Move("c:\test.t xt", "c:\test.xl s")
If the text file is really just a text file, changing its extension will
not convert it to an excel file magically...

If you have a text file, you'll need to parse it and insert the data in
the Excel file. Fortunately, you can use ADO.NET to connect to Excel
files like to a DB (though with some restrictions), so it's not that
complicated to interact with Excel files even in environments where
Excel itself is not available or cannot be automated.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 25 '06 #3
Thanks guys, I haven't tried System.IO.File. Move("c:\test.t xt",
"c:\test.xl s") yet, but I have found that the following code will magically
produce an Excel file with cells A1:A5 populated: This is not documented
anywhere, I just tried it to see what would happen!
Dim pathAndFileName As String = Server.MapPath( "Data/Test.xls")

Dim sr As StreamWriter = File.CreateText (pathAndFileNam e)

Dim xData, str_1,str_2,str _3,str_4,str_5 As String

str_1="This"

str_2="is"

str_3="a"

str_4="Test"

xData = "str_1 & vbTab & str_2 & vbTab & str_3 & vbTab & str_4

sr.WriteLine(xD ata)

sr.Close()
"Laurent Bugnion" <ga*********@bl uewin.chwrote in message
news:O7******** ******@TK2MSFTN GP04.phx.gbl...
Hi,

Augustin Prasanna wrote:
Steve,

System.IO.File. Move("c:\test.t xt", "c:\test.xl s")

If the text file is really just a text file, changing its extension will
not convert it to an excel file magically...

If you have a text file, you'll need to parse it and insert the data in
the Excel file. Fortunately, you can use ADO.NET to connect to Excel
files like to a DB (though with some restrictions), so it's not that
complicated to interact with Excel files even in environments where
Excel itself is not available or cannot be automated.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Aug 25 '06 #4

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

Similar topics

2
4907
by: Anony | last post by:
Hi All, I managed to get Content-Type (i.e. image/gif) from file extension (.gif) in Windows Registry, but the reverse way (from Content-Type to extension) is more tricky. Does anyone know a way to do so? Thanks and regards,
1
10585
by: Tim | last post by:
Hi, What I am trying to accomplish is to initiate remote desktop session from within my C# application to XP Pro machine NOT terminal services to a server. I have not found any way to do this with code (if you know of a way then I would love to hear about it). What I have created so far is; 1. Write RDP file to the HD from the code
13
11654
by: kbperry | last post by:
Hi all, Background: I need some help. I am trying to streamline a process for one of our technical writers. He is using Perforce (version control system), and is constantly changing his word documents, and then converts them to both .pdf and "Web page" format (to publish to the web). He has a licensed copy of Adobe Acrobat Professional (7.x). Questions:
4
4480
by: csgraham74 | last post by:
Hi, Ive posted on this previously but had no response. Basically i need to build some html using a rich text editor. Then i want to actually create an html document from this and save it to my server. Does anyone have any examples on how to do this ?? I dont really understand how to get from HTML string to HTML document. I can probably work out how to save this. do i create an html object ??
6
8664
by: Justin | last post by:
Hi all, i need some help over here... i found the solution to export file from mysql db into *.csv. but is there anyway to convert the contents into *.doc and save in my webserver and providing a link for the end users to download the word file? FYI, the database records are obtained by end users submitting the forms themselve and i saved it in my db... Thanx.
3
2096
by: krishindevnet | last post by:
Hi , I am working on a project which has editor which generates the document templates in HTML .I am required to convert these HTML templates to dot file extension . If anybody knows about that please help me out and guide me overcoming these problem. thanks and regards, Krish
32
10971
by: poolboi | last post by:
hi guys, i've read a lot of thread of converting excel data into CSV files. however, i need a perl script to convert CSV file into excel file now, if required modules is needed, it would be preferable if win32::OLE is used.. currently what i know is when i change my extension as .csv file mannually, it get changed to an excel file through Microsoft Excel CSV file so if i were to use a perl script and convert the perl script has to...
2
10843
by: Muzammil | last post by:
Hi. i learn about cgi scripting in c++ from deitel & deitel. in this book he uses .cgi extension files while when i compile the file on windows platform is .exe. in book he browse the .cgi files i dont know how he makes cgi file.and run in windows xp. can anyone help me to convert exe file into cgi so that i can use this file on redhat apache server. i paste the exe file into cgi-bin folder of apache in windows platform
19
5351
by: est | last post by:
From python manual str( ) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that str(object) does not always attempt to return a string that is acceptable to eval(); its goal is to return a printable string. If no argument is given, returns the empty string, ''.
0
9718
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
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
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...
1
10369
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
7649
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
6876
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.