get rid of comma thousands separator in export

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
MattG
Newbie
Newbie
Posts: 23
Joined: Thu Jun 27, 2013 12:00 am

get rid of comma thousands separator in export

Post by MattG » Sun Oct 27, 2013 2:32 pm

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?
Matt Garrett
CRTech
Boulder, Colorado, USA

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: get rid of comma thousands separator in export

Post by Sandra » Mon Oct 28, 2013 10:33 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MattG
Newbie
Newbie
Posts: 23
Joined: Thu Jun 27, 2013 12:00 am

Re: get rid of comma thousands separator in export

Post by MattG » Mon Oct 28, 2013 7:16 pm

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!
Matt Garrett
CRTech
Boulder, Colorado, USA

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: get rid of comma thousands separator in export

Post by Sandra » Wed Oct 30, 2013 11:18 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MattG
Newbie
Newbie
Posts: 23
Joined: Thu Jun 27, 2013 12:00 am

Re: get rid of comma thousands separator in export

Post by MattG » Thu Oct 31, 2013 6:03 pm

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,
Matt Garrett
CRTech
Boulder, Colorado, USA

MattG
Newbie
Newbie
Posts: 23
Joined: Thu Jun 27, 2013 12:00 am

Re: get rid of comma thousands separator in export

Post by MattG » Thu Oct 31, 2013 7:22 pm

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,
Matt Garrett
CRTech
Boulder, Colorado, USA

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: get rid of comma thousands separator in export

Post by Sandra » Tue Nov 05, 2013 8:45 am

Hello MattG,

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

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: get rid of comma thousands separator in export

Post by Sandra » Thu Nov 07, 2013 10:25 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MattG
Newbie
Newbie
Posts: 23
Joined: Thu Jun 27, 2013 12:00 am

Re: get rid of comma thousands separator in export

Post by MattG » Mon Dec 23, 2013 4:10 pm

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
Matt Garrett
CRTech
Boulder, Colorado, USA

Post Reply