Page 1 of 1

get rid of comma thousands separator in export

Posted: Sun Oct 27, 2013 2:32 pm
by 15666411
When I export a chart to a text file, the exporter inserts commas to separate thousands, e.g., "1,234" instead of "1234". This causes problems for parsing the resultant file, and makes comma-delimited files completely useless. How do I get rid of the thousands separator, or more generally, control the number format of the exported text?

Re: get rid of comma thousands separator in export

Posted: Mon Oct 28, 2013 10:33 am
by 10050769
Hello MattG,

The format of digits of text exportation of TeeChart is the same you have for your computer defined in Region and Language, for this reason, if you doesn't want the thousands are separate commas please change this configuration. To change the configuration please folow next steps:

1.- Going to Control Panel\All Control Panel Items\Region and Language
2.- In first tab, select additional settings.
3.- Change the options as you want.

I hope will helps.

Thanks,

Re: get rid of comma thousands separator in export

Posted: Mon Oct 28, 2013 7:16 pm
by 15666411
Thank you Sandra. It's too bad I can't override the Region and Language settings for TChart export. It's not ideal to have to tell my users to change that setting in order to achieve non-corrupted csv files.

But thanks for the quick response!

Re: get rid of comma thousands separator in export

Posted: Wed Oct 30, 2013 11:18 am
by 10050769
Hello MattG,
You can find an alternative using the Globalizing and Localizing Applications class and try to use the FormatNumber or InvariantCulture. I think these can help you to solve your problem without changing the Region and Language properties. See next link example as apply it in Text Files:
http://msdn.microsoft.com/en-us/library ... s.90).aspx

If it doesn't help you please, let me know and we try to find a concretely solution.

Thanks,

Re: get rid of comma thousands separator in export

Posted: Thu Oct 31, 2013 6:03 pm
by 15666411
Hi Sandra,

I haven't had a chance yet to try FormatNumber or InvariantCulture. Instead, I was looking at another piece of legacy code I maintain; this one references TeeChart v4.0.2010 for .NET 2.0. Unfortunately, it does not seem to check the Region and Language Settings and instead always outputs numbers with commas as thousands separators. Is there something else I can try with that old version? I'd like to avoid updating the references in this legacy code.

Thanks,

Re: get rid of comma thousands separator in export

Posted: Thu Oct 31, 2013 7:22 pm
by 15666411
Okay, I just updated to TeeChart 4.1.2013.5280 for .NET2.0 in the legacy .NET3.5 project, so now I'm using 4.1.2013.528x for a .NET4.0 project and for the .NET3.5 project.

The .NET4.0 program uses the regional settings as described, but the .NET3.5 program still does not, i.e., I'm still seeing commas as thousands separators in the old .NET3.5 program, despite using the same version TeeChart as the .NET4.0 program, for which I was able to remove the commas. Help!

Thank you,

Re: get rid of comma thousands separator in export

Posted: Tue Nov 05, 2013 8:45 am
by 10050769
Hello MattG,

Sorry for the delay. I haven't forgotten your problem, we are working to suggest an answer asap.

Thanks,

Re: get rid of comma thousands separator in export

Posted: Thu Nov 07, 2013 10:25 am
by 10050769
Hello MattG,

Sorry for the delay. If you change the ValueFormat of your series values and you combine it with CultureInfo.InvariantCulture, the format you get in the exportation is the format you expect, without make changes in the computers of your user Please, see next code:

With .Net Framework 4.0 or 4.5

Code: Select all

    public Form1()
    {
      InitializeComponent();
      tChart1 = new TChart();
      //tChart2 = new TChart();
      this.Controls.Add(tChart1);
      //this.Controls.Add(tChart2);
      tChart1.Dock = DockStyle.Top;
      //tChart2.Dock = DockStyle.Bottom;

      InitializeChart();
    }
    private void InitializeChart()
    {
      Steema.TeeChart.Styles.Line series1 = new Line(tChart1.Chart);
      series1.FillSampleValues(1000);
      CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
      tChart1[0].ValueFormat = "##";
      series1.XValues.Name = "TIME";
      series1.YValues.Name = "MAIN.T3";
      tChart1.Draw();
      tChart1.Export.Data.Text.IncludeHeader = true;
      tChart1.Export.Data.Text.IncludeIndex = true;
      tChart1.Export.Data.Text.IndexFieldName = series1.XValues.Name;
      tChart1.Export.Data.Text.Save(@"C:\testChart.txt");
    }
With .Net Framework 3.5:

Code: Select all

 public Form1()
    {
      InitializeComponent();
      tChart1 = new TChart();
      tChart2 = new TChart();
      this.Controls.Add(tChart1);
      this.Controls.Add(tChart2);
      tChart1.Dock = DockStyle.Top;
      tChart2.Dock = DockStyle.Bottom;
      TestVersion3.Properties.Resources.Culture = CultureInfo.InvariantCulture; 
      InitializeChart();
    }
    private void InitializeChart()
    {
      Steema.TeeChart.Styles.Line series1 = new Line(tChart1.Chart);
      series1.FillSampleValues(1000);
      tChart1[0].ValueFormat = "##";
      series1.XValues.Name = "TIME";
      series1.YValues.Name = "MAIN.T3";
      tChart1.Draw();
      tChart1.Export.Data.Text.IncludeHeader = true;
      tChart1.Export.Data.Text.IncludeIndex = true;
      tChart1.Export.Data.Text.IndexFieldName = series1.XValues.Name;
      tChart1.Export.Data.Text.Save(@"C:\testChart3.5.txt");
    }
Could you tell us if my suggestion, works for you?

Thanks,

Re: get rid of comma thousands separator in export

Posted: Mon Dec 23, 2013 4:10 pm
by 15666411
Hi Sandra,

Thank you for the example code.

I was able to control the export format using:

Code: Select all

tChart1[i]->ValueFormat = MyFormatString;
Thanks,
Matt