Excel data connection to API - c#

I have an Excel client and an API and both are under my control. What I want to achieve is a data connection in Excel that can be refreshed by the end user by the click of a button instead of downloading xml/csv/xls files. The benefit would be that the user can have extensive custom charts that don't need to be rebuilt every time a new data set is used, e.g. weekly pivot reports etc.
That is pretty straight forward when using single tenant SQL Server or Access as a data source, however the requirements are a bit different here:
The data has to come through the API as data transformations have to be done.
The user should authenticate with every refresh (i.e. basic auth).
Support for Excel 2010
Data connection "From Web" seems like a good candidate, however this only works with html tables as far as I can tell. OData connections seem to be only offered with Power Query and the Professional Plus packages.
Does it make sense to go down the "From Web" connections route and convert thousands of rows of xml to html or are there other options?
UPDATE
I ended up creating an html table manually which is backwards compatible to Excel 2003 and does not require client-side VBA.

Please check below link it may be help you
http://interoperating.info/courses/perl4data/node/26
http://www.codeproject.com/Tips/463096/Converting-a-datatable-to-CSV-XML-and-HTML-by-usin

You can use ExcelDNA to create an addin that will let the user manipulate (get/set) the data from an Excel sheet, with a C# addin in the background to communicate with the API's XML. The addin works like an advanced VBA addin and can be activated via a button.

Related

How to persist data in Excel (VSTO) shared among few users?

I have to load huge amount of data, pre-process it, share it among few users and finally gather updates back from users.
This is what I did in my previous project -
Created an excel add-in using C++. Loaded the data in memory using the add-in code and processed it. For each type of data I have sent the processed data to a sheet and saved a new excel file. That way, if I have three types of data, I have created three new excel workbooks. My users then opened those new workbooks, made their changes and dropped a text file that contains their changes (through a button). The main excel keeps polling for those updates (text files) and loads them as soon as they are found. That's the way I get the updates back from my users.
I am not a fan of what I did in my previous project, it produces too many temporary files (of course I can delete those). In my current project I want to use C# VSTO Workbook so I can have more control over excel. I was hoping once I load the data, I will ask my users to open the same excel in Read-Only mode and they will make changes. While testing this, I realized user's excel (opened in read-only) mode does not see the loaded data. And their changes do not update the data held in memory. This probably means I have no idea what I am doing.
Do you guys have any idea how to achieve this? I will really appreciate any help/hint.
Excel supports so-called "co-authoring" mode, when many people can edit the same document at the same time. But there is might be a catch: afaik, you need a Share Point/Office Online server/OneDrive Business to support this scenario (you need a non-free office document server product).
Using VSTO, you can do just the same you have done with C++ add-in, but in C# (means, the set of capabilities is 1:1 - it basically just wraps C++ COM Excel API for .NET)
But for online version of Excel, there may be yet another alternative - javascript addins (now that's called "Office Addins", afaik). But I doubt you'd want to process your "huge amounts of data" with javascript.
So I would say, there is a good rule: Don't fix something that isn't broken :)
If the problem is the number of temporary files, these files is not the only option to transfer data between applications. You know, you can connect two applications directly (so that they can exchange data with messages/updates). Use network, Luke :)
Of course if your 3 users live on 3 deserted islands, totally disconnected from anything, exchanging with text files on USB stick may still be the only viable option...
I think the "web" solution could be: store your file in some "co-authoring"-capable service (sharepoint, google shees, onedrive, officeonline, whatever). Make some web job to update that file in that storage automatically. Just like a "fourth" user would do.

Best Way to generate excel report

Actually I'm asking this question because I want to know what is best solution for this base on what I only have. First let me show you what I really want to achieve. My boss want me to generate report in excel file (.xls or xlxs) then inside this report compose of multiple sheets with each respective sheet name. Data are presented in nice and professional way and sometime there are graphs inside that are link with the data within the sheet and it looks like this:
Below is what I only have to generate this output.
Visual Studio 2008
Sql Server 2008 (no SSRS)
Report is generated via
RDLC (naming of sheet is not possible for this but multiple sheet is
doable via pagebreak)
I try to update excel file via Sql Server but
seem too complicated for this specially when dealing with Total
fields.
I have not yet tried to render graph on .rdlc
It sounds like the data lives in SQL server. If you have access to it, why not create an ODBC connection and use this to pull raw data into each one of the sheets you need, and then configure a dashboard tab that automatically pulls data from those sheets (even if you refresh it) and shows the graphs and summary tables in the format that you want?

Writing to an Excel file from SQL Server Database

Currently, I need to be able to retrieve values from an SQL Server DB, populate an Excel file according to a certain template, and then allow the user to download the file. I also need this this certain template to be customizable, in the sense that the user can add new fields, and remove fields.
I understand that there are a couple of approaches I can take: using .xlt, and using C# directly. With C#, the user will need to interact with a UI, which will then populate a ExcelTemplate table in the SQL Server. This ExcelTemplate table will then be used when the user wishes to download a new Excel file.
I know all this stuff may sound kinda abstract, so please do tell me if there are some places I need to elaborate/clarify. Thanks a bunch, man.
EDIT: Sorry, I kinda missed this part out, but I'd prefer to allow the user to customize these Excel templates via a Silverlight UI.
You can create Data Sources in Excel and pull the data from MS SQL Server.
You can use MS Reporting Services which allow to get reports in MS Excel format. In this case users can use Report Builder to customize the reports.
For pulling down data from SQL Server and dumping it into Excel, you can use Officewriter. It has Reporting Services integration and supports generating .xls and .xlsx documents. There's also a template component that basically does what you're trying to do. The templates are actually Excel documents, so the users can edit them directly in Excel. Not Silverlight, but not bad. You can try an eval for free.
DISCLAIMER: I'm one of the engineers who built the latest version.
at the end of the day I think I'm gonna spend some time building a customized dashboard. It won't be generic, but rather focused on the existing database.
I know this answer is kinda vague and all, but I'd like to say thanks for all the help :) it'd be great if there are dynamic solutions for this in the future! I think...

Call out to web service from Excel 2010

Starting an innovation week at work here. Good ol' Excel project! So here's what we want. We want to be able to create user defined functions in Excel, just like Excel has the SUM, etc. we want to make our own.
These UDF's would take Excel data in, and they would then pass that data to a Web Service which would do what it needs to do and then return the data back. I know how the Web Services will act, but what I need some guidance on is preparing the data in Excel, setting up the UDF's, and dealing with the sending/receiving of the data in Excel. I've never done any Excel programming before.
At first glance, it seems I might not need to do any VBA work, and that I could almost create a plugin for Excel (generate a .xll file from C#), and then go about it this way, but I'm not really sure how this all works.
Am I approaching this right? Are there any other things I should keep in mind? Is there anything I should read up on (any good links)?
Thanks.
There are good articles like below on MSDN.
Article 1
Article 2
Videos on Youtube and other
Video 1
Video 2
You can call a WCF service from Excel with VSTO or with VBA
You will want to use VSTO to create an add-on for Excel. Using Visual Studio create a new project. Select Office and then Excel 2007 Add-on or Excel 2010 Add-on. Check out this great resource for examples on how to get started http://www.packtpub.com/article/microsoft-office-excel-programming-using-vsto it pretty much has everything you are asking for (except calling a web service).
It may be possible to do all of this in VBA but it won't be as easy and you'll have to deal with the security issues that come with it.
You could take a look at XLLoop. This is a framework for developing Excel UDFs on a remote server. It has server implementations in a range of languages and is open source with a liberal license.
(Full disclosure: I work on this project).

how to update text in a powerpoint slide using C#

i have a single powerpoint slide that we use for reporting. This slidehas some tables and some textboxes with bulletted lists
We are trying to see if we can update this powerpoint slide (update text in textbox and update text in tables) using C# as we now have a lot of the data that we manually add to this slide in a SQL database.
so i basically need to:
load up current presentation and this single slide (treat it like a template)
access textboxes and clear current text
enter new text from my data source (happens to be SQL server)
update tables
save as specific filename
what is the best way of doing this from C#. i want to basically have a button in a webpage or a winforms app that kicks off the steps above.
Update
Looking for a FREE solution if possible (a few answers below are paid third party libraries)
If you are working with any PowerPoint file formats (including the default one used by PowerPoint 2003), you have to use Microsoft Office & PowerPoint Interops. There are probably some third party libraries, but I'm not sure they will be very helpful in this particular situation, except if you don't want to or can't install Microsoft Office on the server.
If you use only the new PowerPoint 2007 format or 2003/2007 XML format, then changing the XML directly may be the easiest way, thus this does not require Microsoft Office to be installed on the server.
You may want to look at Aspose for .NET. It provides a ton of libraries for interfacing with Office file formats.

Categories

Resources