Welcome to the Xceed Community | Help
Community Search  
More Search Options

format in Exporting

Sort Posts: Previous Next
  •  07-10-2012, 3:12 AM Post no. 32369

    format in Exporting

    Hello,

    I want to export my data to excel & csv files.

    I have some columns with numeric data and I want that they will be shown as text columns in the file. (It is neccacery for me, becouse the numbers are very long - more than 15 digits, and the excel doesn't know display it as well, unless the column is defined as text from the beginning)

    I'm try use with the FormatSetting.NumericFormat but nothing happens..

    this is my code:

     using (Stream stream = saveFileDialog.OpenFile())

                        {

                            CsvExporter exporter = new CsvExporter(MyXceedGrid);

                            exporter.FormatSettings.Culture = System.Globalization.CultureInfo.CurrentCulture;

                            exporter.FormatSettings.NumericFormat = "#";//or 0.0000, or any something else

                            exporter.Export(stream);

                        } 

    So Please -

    1. How really use with the FormatSetting ? what is wrong in my code?

    2. Why the  CsvExporter provides the FormatSetting, but the ExcelExporter not? (my version is 4.2.11215.9190)

    Thanks. 

  •  07-17-2012, 3:10 PM Post no. 32416 in reply to 32369

    Re: format in Exporting

    Hi Rachel,

    In your code snippet, using the number sign(#) only as a NumericFormat will do nothing. In fact, Excel, will expect the format to come after the number sign(#). For example, I used "#0.0" as a numeric format and that worked fine. However, you could use the FormatSettings class to modify the format of your data, but not its data type. Therefore, it can not be used to convert a numeric column to a String one.
     In regards to your second question, unfortunately, the ExcelExporter class, does not have the FormatSettings feature implemented yet.
     
     

    Fawzi Bablli
    Developer Technical Support
    Xceed Software Inc.
  •  07-18-2012, 7:05 AM Post no. 32419 in reply to 32416

    Re: format in Exporting

    1. So Is another way to convert the column from numeric to string?

    2. Although the type of the column is string, but the data contains only digits - the excel display the column as numbers, not as text. - Do you have any solution for display it as text in the file?

     thanks.

  •  08-07-2012, 7:29 AM Post no. 32525 in reply to 32419

    Re: format in Exporting

    Do you have any solution for this?
  •  08-07-2012, 4:37 PM Post no. 32529 in reply to 32525

    Re: format in Exporting

    Hi Rachel,

    From what you have described in your previous reply, the column's DataType is String but Excel displays it as numbers. This is how the Excel formatter works, it displays numeric values as numbers, even if the underlying data type is String. Unfortunately, this issue  falls outside the scope of our support, since it is an Excel issue not a DataGrid one.


    Fawzi Bablli
    Developer Technical Support
    Xceed Software Inc.
  •  08-08-2012, 8:35 AM Post no. 32531 in reply to 32529

    Re: format in Exporting

    it's says that the only way to solve this problem is - not use with your exporting at all, and do it myself -

    I can define the excel columns as string!

     

      Excel.Application xlApp = new Excel.Application();

      Excel.Workbook xlWorkBook = xlApp.Workbooks.Add(misValue);

      Excel.Worksheet xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

      chartRange = xlWorkSheet.get_Range("e5", "e6");

      chartRange.NumberFormat = "@";

      xlWorkSheet.Cells[5, 5] = 123456789123456789; 

     

    and it works !! this long number displayed in the excel as well ! 

     


         

  •  08-15-2012, 1:23 AM Post no. 32565 in reply to 32531

    Re: format in Exporting

    Please let me know if I'm wrong and you have another solution...
  •  08-16-2012, 2:11 PM Post no. 32575 in reply to 32565

    Re: format in Exporting

    Hi Rachel,

    As I explained in my previous reply, this issue falls outside the scope of our support since it is not an issue with an Xceed product. Therefore, I cannot confirm if your solution, which does not contains any Xceed class or method, is valid or not. We apologize for any inconvenience this might cause you.


    Fawzi Bablli
    Developer Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.