The Spotfire Community is moving to TIBCOmmunity and this forum location has closed. During the transition, you can still search the old forums but posting has been disabled. We encourage you to pick up the discussion at the new Spotfire community on TIBCOmmunity.
Using C# to read excel files automatically as defined by the user using API's - TIBCO Spotfire Community

Using C# to read excel files automatically as defined by the user using API's

Last post Fri, May 11 2012 10:50 PM by jhjm. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • Wed, May 9 2012 3:13 PM

    Using C# to read excel files automatically as defined by the user using API's

    Hi, I want to create a data table to be read from excel files, defined from an input field inserted in a text box. The idea is that the user may choose to look at a different asset file that has the same structure but different values - information. The files are located and updated regularly (daily) on a share drive and these are excel files, there is a number of assets and each asset has it's own file. My idea is to do this using the API's and have been trying to use a DatabaseDataSource construct, but have not been able to succeed. Has anyone done this, I keep thinking there must be an easy way to do this... Any help is appreciated. Thanks My code is included below: internal void addTable() { AnalysisApplication mainApp = GetService(); AggregatedTransactionHandle toolTransaction = mainApp.Document.Transactions.BeginAggregatedTransaction(); bool successful = false; string Path1 = Convert.ToString(mainApp.Document.Properties["DashboardProductionPath"]); string table1 = Convert.ToString(mainApp.Document.Properties["DashboardProductionReport"]); if (File.Exists(Path1)) { string stringProvider = Convert.ToString("Microsoft.jet.OLEDB.4.0"); string connectionString = Convert.ToString("Data Source = " + Path1 + ";Extended Properties = Excel 8.0"); string sqlStatement = Convert.ToString("page = Report"); DatabaseDataSourceSettings dbSettings1 = new DatabaseDataSourceSettings(stringProvider, connectionString, sqlStatement); DatabaseDataSource dbSource1 = new DatabaseDataSource(dbSettings1); try { if (mainApp.Document.Data.Tables.Contains(table1)) { mainApp.Document.Data.Tables[table1].ReplaceData(dbSource1); } else { mainApp.Document.Data.Tables.Add(table1, dbSource1); } successful = true; } catch (ProgressCanceledException) { successful = false; } if (successful) { toolTransaction.Commit(); } else { toolTransaction.Rollback(); } } }
  • Fri, May 11 2012 10:50 PM In reply to

    • jhjm
    • Top 75 Contributor
    • Joined on Sat, Nov 5 2011
    • Posts 27

    Re: Using C# to read excel files automatically as defined by the user using API's

     

    With a white leather upper and voltage cherry accents the hits of silver that also line the sneakers upper are an added bonus. wholesale designer handbags are not so hard to uncover anymore. There are so several outlets which supply these Cheap handbags for a really inexpensive price tag. You just have to know the place you should go and you can now go on a searching spree. There are websites, vintage shop and even division retailers that offer designer Cheap designer handbags for a low price. You require to seem cautiously when you want to This can make it much more exciting to shop particularly when you see that a huge % of the price tag had been slashed off. The nike air max 1 has dropped in a variety of colorways so far this year, and today we’re getting a look at yet another version that is now making its rounds. The Hyperfuse built upper is light and breathable, making these perfect for running or casual wear. All the while, the shoe blends a mix of white, metallic silver, and anthracite. Finishing off the look is a cheap air max trainers unit that runs the length of the shoe.ewr

     dr

Page 1 of 1 (2 items)
©Copyright 2000-2011 TIBCO Software Inc | Privacy Policy | Terms of Use I Blog I Contact Us I Content Center