Excel as a DataSource for Line Series
Excel as a DataSource for Line Series
I want to add a feature to import Excel data into a line series. Where is the documentation for the API? I'm using Visual Studio 2013, C++, TeeChart Pro ActiveX 2015.
Also, if you could point me to a tutorial or anything in the feature demo.
Regards.
Also, if you could point me to a tutorial or anything in the feature demo.
Regards.
Re: Excel as a DataSource for Line Series
Hello,
You can do it at designtime, selecting "Excel" as datasource for the series:
You can do it at designtime, selecting "Excel" as datasource for the series:
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Excel as a DataSource for Line Series
Hello again,
Here an example loading data from an xls at runtime with C#:
Here an example loading data from an xls at runtime with C#:
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
axTChart1.AddSeries(TeeChart.ESeriesClass.scBar);
OleDbConnection dbConnection;
OleDbDataAdapter dbAdapter;
//Connection string to the Excel spreadsheet. HDR states that the sheet has row headings.
string conString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=F:\\Downloads\\ImportExcelSheet_AX_CSharp\\charts.xls;" +
"Extended Properties='Excel 8.0;HDR=Yes'";
try
{
dbConnection = new OleDbConnection(conString);
dbConnection.Open();
dbAdapter = new OleDbDataAdapter("SELECT * FROM [Charts.CSV.$]", dbConnection);
DataSet ds = new DataSet();
dbAdapter.Fill(ds, "MyData");
int i = 0;
axTChart1.Axis.Bottom.Labels.Clear();
foreach (DataRow dbRow in ds.Tables["MyData"].Rows)
{
if (dbRow[0].ToString() != "")
axTChart1.Series(0).Add(Convert.ToDouble(dbRow[2]), dbRow[1].ToString(), Convert.ToUInt32(TeeChart.EConstants.clTeeColor));
axTChart1.Axis.Bottom.Labels.Add(i, dbRow[0].ToString());
i++;
}
axTChart1.Axis.Bottom.Labels.Angle = 90;
ds.Dispose();
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message);
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
//
}
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Excel as a DataSource for Line Series
I need to have a C++ equivalent for OleDBConnection as the rest of my code is in C++ not C#.
I cannot link/compile with "System.data.OleDB" What is the alternative? Is there an API that is available via TChart classes that I can use directly instead of going through OLDB?
Regards.
I cannot link/compile with "System.data.OleDB" What is the alternative? Is there an API that is available via TChart classes that I can use directly instead of going through OLDB?
Regards.
Re: Excel as a DataSource for Line Series
Can I possibly do it with the Series.SetDataSource() call instead of OleDB?
If so, how can I set up the connection string etc.?
I would like to see an example.
Thanks.
If so, how can I set up the connection string etc.?
I would like to see an example.
Thanks.
Re: Excel as a DataSource for Line Series
Hello,
I'm not sure to understand why can't you use OleDbConnection. According to this, it should be able to use OleDbConnection in C++.
I'm not sure to understand why can't you use OleDbConnection. According to this, it should be able to use OleDbConnection in C++.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Excel as a DataSource for Line Series
Thanks for the reply.
Yes, it looks like we can use OldDBConnection class in C++ from the above link. However, I am still having issues. What do I need to include or what reference to do I need to add to my Visual C++/MFC project so that I can use the OleDB objects? I have the following:
#include <oledb.h>
OleDbConnection myConnection;
I get an undefined object for OleDbConnection.
error C2065: 'OleDbConnection' : undeclared identifier
If I try to add ATL support to my MFC project I get an error saying "ATL support can only be added to MFC exes or MFC Regular DLLs'
Not sure what is going on. Any help would be appreciated.
Yes, it looks like we can use OldDBConnection class in C++ from the above link. However, I am still having issues. What do I need to include or what reference to do I need to add to my Visual C++/MFC project so that I can use the OleDB objects? I have the following:
#include <oledb.h>
OleDbConnection myConnection;
I get an undefined object for OleDbConnection.
error C2065: 'OleDbConnection' : undeclared identifier
If I try to add ATL support to my MFC project I get an error saying "ATL support can only be added to MFC exes or MFC Regular DLLs'
Not sure what is going on. Any help would be appreciated.
Re: Excel as a DataSource for Line Series
Hello,
http://www.tech-archive.net/Archive/Dat ... 00011.html
I hope it will help.
Here it is a user with a similar error that found a way to make it work:nbp wrote:error C2065: 'OleDbConnection' : undeclared identifier
http://www.tech-archive.net/Archive/Dat ... 00011.html
I hope it will help.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Excel as a DataSource for Line Series
Thanks. That helped. I was able to progress. However, I've run into some issues. I needed to compile my DLL that references TChart objects with /clr in order to add references to "system" and "system.data" and use OleDB components. So my DLL is now mixed mode. My calling program is native and when it loads this DLL, I ran into the loader lock problem when loading mixed dlls or a combination of managed and native DLLs. I got past this issue by adding the /NoEntry option to the linker.
But now I'm running into a problem allocating memory while initializing TChart. It seems like I've got into an endless loop of changing compiler/linker settings in my DLL that was originally a native DLL, in order to access OleDB components.
Is there any way around this? Is there any plan in the future to provide a TChart class (API) for Excel import that we can interface with instead of going via the OleDB route? This would be a much cleaner approach for us.
But now I'm running into a problem allocating memory while initializing TChart. It seems like I've got into an endless loop of changing compiler/linker settings in my DLL that was originally a native DLL, in order to access OleDB components.
Is there any way around this? Is there any plan in the future to provide a TChart class (API) for Excel import that we can interface with instead of going via the OleDB route? This would be a much cleaner approach for us.
Re: Excel as a DataSource for Line Series
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Excel as a DataSource for Line Series
Hello,
Studying what impact of implementing such feature, we realized a simple example we can run as-is would help us to see how are you exactly doing this and it would allow us to debug the sources to see if there's a bug in TeeChart ending in the allocating memory problem you described:Yeray wrote: I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1342
So could you please try to arrange a simple example project we can run as-is to reproduce the problem here?nbp wrote:But now I'm running into a problem allocating memory while initializing TChart.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |