Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7763211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:36:18+00:00 2026-06-01T14:36:18+00:00

MS Excel has eaten my head. It is randomly converting numbers into scientific notation

  • 0

MS Excel has eaten my head. It is randomly converting numbers into scientific notation format. This causes a problem when I load the file saved in tab delimited format into SQL Server. I know I can provide a format file and do lot of fancy stuff. But let’s say I can’t.

Is there a macro which loops over all the cells and if the number in a cell is in scientific notation format then it converts it to numeric format?

Say:

Input: spaces signify different cells.
1.00E13 egalitarian 

Output after macro:

10000000000000 egalitarian

I am trying this in Excel 2007.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:36:19+00:00Added an answer on June 1, 2026 at 2:36 pm

    I wrote a simple C# program to resolve this issue. Hope it’s of use.

    Input:

    Input directory where files reside (assuming files are in .txt format).

    Output:

    Output directory where converted files will be spit out.

    Delimiter:

    Column delimiter.

    The code

    using System;
    using System.Text.RegularExpressions;
    using System.IO;
    using System.Text;
    using System.Threading;
    
    namespace ConvertToNumber
    {
        class Program
        {
            private static string ToLongString(double input)
            {
                string str = input.ToString().ToUpper();
    
                // If string representation was collapsed from scientific notation, just return it:
                if (!str.Contains("E")) 
                    return str;
    
                var positive = true;
                if (input < 0)
                {
                    positive = false;
                }
    
                string sep = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
                char decSeparator = sep.ToCharArray()[0];
    
                string[] exponentParts = str.Split('E');
                string[] decimalParts = exponentParts[0].Split(decSeparator);
    
                // Fix missing decimal point:
                if (decimalParts.Length == 1) 
                    decimalParts = new string[] { exponentParts[0], "0" };
    
                int exponentValue = int.Parse(exponentParts[1]);
    
                string newNumber = decimalParts[0].Replace("-","").
                    Replace("+","") + decimalParts[1];
    
                string result;
    
                if (exponentValue > 0)
                {
                    if(positive)
                        result =
                           newNumber +
                           GetZeros(exponentValue - decimalParts[1].Length);
                    else
                        result = "-"+
                         newNumber +
                         GetZeros(exponentValue - decimalParts[1].Length);
    
    
                }
                else // Negative exponent
                {
                    if(positive)
                        result =
                            "0" +
                            decSeparator +
                            GetZeros(exponentValue + decimalParts[0].Replace("-", "").
                                       Replace("+", "").Length) + newNumber;
                    else
                        result =
                        "-0" +
                        decSeparator +
                        GetZeros(exponentValue + decimalParts[0].Replace("-", "").
                                 Replace("+", "").Length) + newNumber;
    
                    result = result.TrimEnd('0');
                }
                float temp = 0.00F;
    
                if (float.TryParse(result, out temp))
                {
                    return result;
                }
                throw new  Exception();
            }
    
            private static string GetZeros(int zeroCount)
            {
                if (zeroCount < 0)
                    zeroCount = Math.Abs(zeroCount);
    
                StringBuilder sb = new StringBuilder();
    
                for (int i = 0; i < zeroCount; i++) sb.Append("0");
    
                return sb.ToString();
            }
    
            static void Main(string[] args)
            {
                //Get Input Directory.
                Console.WriteLine(@"Enter the Input Directory");
                var readLine = Console.ReadLine();
                if (readLine == null)
                {
                    Console.WriteLine(@"Enter the input path properly.");
                    return;
                }
                var pathToInputDirectory = readLine.Trim();
    
                //Get Output Directory.
                Console.WriteLine(@"Enter the Output Directory");
                readLine = Console.ReadLine();
                if (readLine == null)
                {
                    Console.WriteLine(@"Enter the output path properly.");
                    return;
                }
                var pathToOutputDirectory = readLine.Trim();
    
                //Get Delimiter.
                Console.WriteLine("Enter the delimiter;");
                var columnDelimiter = (char) Console.Read();
    
                //Loop over all files in the directory.
                foreach (var inputFileName in Directory.GetFiles(pathToInputDirectory))
                {
                    var outputFileWithouthNumbersInScientificNotation = string.Empty;
                    Console.WriteLine("Started operation on File : " + inputFileName);
    
                    if (File.Exists(inputFileName))
                    {
                        // Read the file
                        using (var file = new StreamReader(inputFileName))
                        {
                            string line;
                            while ((line = file.ReadLine()) != null)
                            {
                                String[] columns = line.Split(columnDelimiter);
                                var duplicateLine = string.Empty;
                                int lengthOfColumns = columns.Length;
                                int counter = 1;
                                foreach (var column in columns)
                                {
                                    var columnDuplicate = column;
                                    try
                                    {
                                        if (Regex.IsMatch(columnDuplicate.Trim(),
                                                          @"^[+-]?[0-9]+(\.[0-9]+)?[E]([+-]?[0-9]+)$",
                                                          RegexOptions.IgnoreCase))
                                        {
                                            Console.WriteLine("Regular expression matched for this :" + column);
    
                                            columnDuplicate = ToLongString(Double.Parse
                                                                               (column,
                                                                                System.Globalization.NumberStyles.Float));
    
                                            Console.WriteLine("Converted this no in scientific notation " +
                                                              "" + column + "  to this number " +
                                                              columnDuplicate);
                                        }
                                    }
                                    catch (Exception)
                                    {
    
                                    }
                                    duplicateLine = duplicateLine + columnDuplicate;
    
                                    if (counter != lengthOfColumns)
                                    {
                                        duplicateLine = duplicateLine + columnDelimiter.ToString();
                                    }
                                    counter++;
                                }
                                duplicateLine = duplicateLine + Environment.NewLine;
                                outputFileWithouthNumbersInScientificNotation = outputFileWithouthNumbersInScientificNotation + duplicateLine;
                            }
    
                            file.Close();
                        }
    
                        var outputFilePathWithoutNumbersInScientificNotation
                            = Path.Combine(pathToOutputDirectory, Path.GetFileName(inputFileName));
    
                        //Create the directory if it does not exist.
                        if (!Directory.Exists(pathToOutputDirectory))
                            Directory.CreateDirectory(pathToOutputDirectory);
    
                        using (var outputFile =
                            new StreamWriter(outputFilePathWithoutNumbersInScientificNotation))
                        {
                            outputFile.Write(outputFileWithouthNumbersInScientificNotation);
                            outputFile.Close();
                        }
    
                        Console.WriteLine("The transformed file is here :" +
                            outputFilePathWithoutNumbersInScientificNotation);
                    }
                }
            }
        }
    }
    

    This works fairly well in case of huge files which we are unable to open in MS Excel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Excel has a Conditional Formatting... option under the Format menu that allows you to
I am outputting data from my DB to Excel (has to be .xls format),
I am exporting an excel workbook into xml spreadsheet. The excel has lets say
Microsoft Excel has a nice Text Import Wizard to help load files that are
I have a flat file source from Excel that has a structure like this:
Until Office 2007, Excel has a maximum of 65,000 rows. Office 2007 bumped that
I have an excel file which has more than 65536 rows. However, I can
I have an Excel file that has a bunch of VBA and macro code
So I have an excel workbook that has a nice global map of shaperange
I have an excel spreadsheet that has two columns. When I choose to save

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.