Hi,
I have follwing C# code which opens that tab delimited .txt file and does the saveas to Excel file. Problem what I am running into is some of the text field has value such as "91010105212974 61515213" is getting converted to "9.10101E+2 1". How do I prevent getting converted to scientific notation and leave as text instead using below function ? -
public void SaveTextFileAsExcel(string filefrompath, string filetopath, string newtabname)
-
{
-
// Excel object references.
-
Excel.Application m_objExcel = new Excel.Application();
-
Excel.Workbooks m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
-
Excel._Workbook m_objBook = null;
-
Excel.Sheets m_objSheets = null;
-
Excel._Worksheet m_objSheet = null;
-
// Frequenty-used variable for optional arguments.
-
object m_objOpt = System.Reflection.Missing.Value;
-
if (filefrompath != "")
-
{
-
m_objBooks.OpenText(filefrompath, Excel.XlPlatform.xlWindows,1,
-
Excel.XlTextParsingType.xlDelimited, Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
-
false, true, false, false, false, false,m_objOpt, m_objOpt,
-
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
-
-
-
m_objBook = m_objExcel.ActiveWorkbook;
-
m_objSheets = m_objBook.Worksheets;
-
-
m_objSheet = (Excel.Worksheet)m_objSheets.get_Item(1);//Get the reference of second worksheet
-
-
string strWorksheetName = m_objSheet.Name;//Get the name of worksheet.
-
if (newtabname != "") { m_objSheet.Name = newtabname; }
-
-
if (filetopath !="")
-
{
-
// Save the text file in the typical workbook format and quit Excel.
-
m_objBook.SaveAs(filetopath, Excel.XlFileFormat.xlWorkbookNormal,
-
m_objOpt, m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange, m_objOpt, m_objOpt,
-
m_objOpt, m_objOpt, m_objOpt);
-
} //if (filetopath !="")
-
} //if (filefrompath != "")
-
-
m_objBook.Close(false, m_objOpt, m_objOpt);
-
m_objExcel.Quit();
-
} //SaveAsExcel
-
0 1200 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: masoud bayan |
last post by:
I have some values in type of double such 0.00009 , 0.0000007, when I want
to show them in a text box and convert them to string they are changed to
scientific notation while I want to show them as they are.
I tried to use tostring("f") but it needs to have a precision number after
*f* which will cause always have fix number of characters (for example if
use f10 then 0.09 is converted to 0.09000000 while I need to show it as
0.09).
do...
|
by: Nick |
last post by:
Well, the project I am working on has now come to a screeching halt! I
have been developing a program that heavily utilizes ADO.NET record
sets. To generate reports, I convert the recordset to XML, and then
apply an XSLT to transform the XML into HTML. This works great (or
did) until today. I just found out that the "number-format" command in
XSLT can't handle scientific notation! So when I try to format these
numbers I just get "NaN" on...
|
by: Greg |
last post by:
I am working on an application that requires working with numbers in
scientific notation. I am using SqlServer as the database and I have
created strongly typed data adapters and datasets. The numbers are
defined as numeric in the SqlServer Database and are bound to text
boxes in the app. In the dataset xml these numbers are defined as
decimal. I am using the binding method Format to display the data in
scientific notation and Parse to...
|
by: Dustan |
last post by:
How can I get a number into scientific notation? I have a preference
for the format '1 E 50' (as an example), but if it's well known, it
works.
|
by: Joe Attardi |
last post by:
Hi all,
Math is not my strongest area so forgive me if I use some of the wrong
terminology.
It seems that scientific notation is immune to rounding errors. For
example:
(4.98 * 100) + 5.51 // returns 503.51000000000005, rounding error!
4.98e2 + 5.51 // returns 503.51, correct!
| |
by: rSmoke |
last post by:
I have a DataSet that contains a table with about 6 columns of high accuracy
decimal values. When I try to write out the DataSet using the WriteXML()
function the XML is written fine, but the decimal values are written out in
scientific notation ("9.984348392E+08"). This wouldn't be a problem except
when I try to READ the XML file back into a DataSet I keep getting a
System.FormatException saying "Input string was not in a correct format."...
|
by: Greg |
last post by:
I am working on an application that requires working with numbers in
scientific notation. I am using SqlServer as the database and I have
created strongly typed data adapters and datasets. The numbers are
defined as numeric in the SqlServer Database and are bound to text
boxes in the app. In the dataset's xml these numbers are defined as
decimal. I am using the binding method Format to display the data in
scientific notation and Parse to...
|
by: MLH |
last post by:
Textbox on report displays year (1991) in scientific notation
if I raise the font size in that control to above 16 points. It
seems Access 'thinks' 1991 is too big to display properly in the
control, so it reverts to displaying the value in scientific no-
tation (rather stupidly from my standpoint). I don't want that
but it seems I can do nothing about it. Any suggestions.
Report's RecordSource is a query and this IS a bound control.
|
by: themadjester |
last post by:
http://www.themadjester.com/images/excellesigh.GIF
(hover cursor over box to see image of formula that cannot be copied correctly from excel (rabble rabble rabble))
So I made a 6th degree equation from a trendline in excel...
If anyone can tell me what this is supposed to mean they can have a cookie* >.>. I know scientific notation, but it seems to me that regular SN is not good enough for microsoft, I mean, why would they put another...
|
by: prashantdixit |
last post by:
Hi,
I am trying to generate Linear Trendline Equation for a graph using VBA in Excel 2007.
I am able to do it. However It always generate trendline equation in "General" Format.
And i want to display linear trendline equation oin graph in "scientific notation" upto 5 decimal places using VBA code.
The code which i have written for generating Linear Trendline Equation is:
ActiveChart.SeriesCollection(1).Trendlines.Add...
|
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,...
| |
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...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |