views:

37

answers:

1

How to read Excel data having Number format ;;; ie hidden value in C# using spreadsheet gear.

A: 

I am not sure that I understand your question. This code writes the formatted value of a cell, the number format and the unformatted value:

using System;

namespace WriteFormattedCellWithSpreadsheetGear
{
    class Program
    {
        static void Main(string[] args)
        {
            var workbook = SpreadsheetGear.Factory.GetWorkbook(@"C:\tmp\MyWorkbook.xlsx");
            var worksheet = workbook.Worksheets[0];
            var a1 = worksheet.Cells["A1"];
            // Write the formatted data
            Console.WriteLine("Text={0}", a1.Text);
            // Write the number format
            Console.WriteLine("NumberFormat={0}", a1.NumberFormat);
            // Write the raw data
            Console.WriteLine("Value={0}", a1.Value);
        }
    }
}
Joe Erickson