How to get Excel to interact with .NET or PowerShell or OData - excel

I have a few thousand rows of history data that I want Excel to access. This data will be used in creating a summary report, sparklines, and a table data.
My question is how should I go about adding new rows to the datasource? Powershell is required to extract data from the source (Exchange Server)... but then how do I surface that extracted data to Excel2010?
Here are my ideas:
1) Powershell can run externally and save the data to the XLSX (as long as the spreadsheet is closed) using Open XML libraries
2) Use Excel vb macros to call COM via interop (C# object) to get the data from Powershell. The returned values go to the XLSX (Ugly)
3) ????
(Advanced, not sure if this idea will work with above mentioned features)
If I were to move these rows to an external sheet, or SQL table, then I'd rather use other ways of importing the data into excel. I dont' know if this will work with sparklines, or tables. Perhaps I could use OData since it appears to be the most lightweight and firewall friendly.

If you have the external data in SQL Server, Access or another Excel file, it's trivial to access it using Data>Connections. The data will automatically be formatted as an Excel table with all of Excel's features available.

Related

Using Logic Apps to read Excel from sharepoint online and then inserting into Azure SQL

I am trying to do something that should be fairly simple, but I get no results.
I want to read an Excel file from our sharepoint site (O365) and insert the data from the first worksheet into a table in SQL Server.
Actually quite simple and straightforward. Well, it sounds like that.......
Apparently there is more than reading the file and inserting the file into SQL Server....
Who can provide me with info, tutorials or (even better) step-by-step instructions?
Bonus would be looping through the (online) folder and importing all excel files creating a table for each worksheet.
Edit: I am able to collect the Excel file and email it to me as an attachment.
I just have no clue how to insert it in SQL Server.
This is possible in 4 steps:
Trigger (duh)
Excel Business component - Get Tables
For each component - Value (list of items)
SQL Server component - Insert Row (V2) _ make sure you create parameters for all the columns and map them to the dynamic content offered
(I inserted a SQL Server component - Execute query after step 2 to truncate the destination table)
Not looping yet but this at least enables me to insert rows from an online Excel into a Azure SQL
You can use Azure Data Factory for that, create the connection to your excel file, then to SQL, and use a copy & transform Pipeline

Excel PowerPivot - change data source type

I have an Excel 2016 with 30 graphs based on PowerPivot. PowerPivot fetches the data from another Excel sheet, but I want it to get the data from a SQL server table instead.
How can I change the data source type in PowerPivot? I've tried looking in the Excel xml without any luck. Would be a lot of work re-creating all graphs over again just to switch data source
Thanks
Dennis
One suggestion I would make for the future, if all the users are using 2016 is to use Power Query which comes standard with that version of excel. In the Power Query loading data into Power Pivot scenario, all Power Pivot cares about is the column names. This means that the query can be changed between data source types without causing issues, as long as the same column names are changed.
As an example, I have one file that based on a parameter flag rips data out of a series of excel files on a shared network drive or Share Point. Both of which would be different data sources. The first opening a folder as the data source, then excel files listed within the folder. The other opening a share point list as its data source, then navigating though excel files.

Consumer PowerPivot/Excel DataModel from another Excel file?

Short version: Is there any way/hack to use the embedded DataModel/PowerPivot cube of an Excel 2013/6 file from another Excel file?
Long version:
We have a large Excel Data Model with >400k rows and >100 measurements, feeding multiple reports (i.e. PivotTable on separate worksheets). As all this is growing, we want to split this out into a (large) data model and multiple reports. I know this could be done with SharePoint or PowerBI - however one of the key requirements is to be able to analyse the data offline. Hence, I'm trying to figure out any way to connect to the data model from another file....
There's no way that I know to do what you're asking. Is there any reason you can't just include all the reports in one workbook with the data model? Since you have to be able to analyze offline, anyway, everyone will need a local copy of the model. If the concern is just that there will be too many sheets in a single workbook, you could just put a thin veneer of VBA in it to hide and unhide sheets in groups for ease of use.
It looks like Microsoft has added an option to establish connection via ODC file.
See this f.e. https://learn.microsoft.com/en-us/sql/reporting-services/report-data/use-an-office-data-connection-odc-with-reports?view=sql-server-ver15
However it's not working out for me, I am using Excel 2016, exported data model from the file with data model as a separate odc file but when I try to add this as a connection in another file - I get the message - can't open the file. Looks like creating ODC file is not that straightforward.
Anyone had similar issues?

VBA as data source for Excel

I would like to have VBA generate some data for an Excel Pivot table. VBA will then recalulate the data and the pivot will update based on that.
Question: Is it possible to have VBA be a direct data source for the pivot or do I need to write down in a file from VBA and have the pitot refresh itself from there?
The direct data source gives me the advantage that I can create multi-dimensional data and not only a 2D matrix.
I can see I can choose a lot of data sources and I could write some data in one of these formats from VBA.
So for example I could choose to generate an xml file from VBA, and then have a pivot table use that xml file as its source. I guess it would be a bad idea to emulate the OLAP cubes from the SQL Server in VBA!
Damian
For OLAP cubes, the Microsoft Excel is a very good viewer, but if you have access to Analysis Server tool, you will prefer use it.
But, Excel can connect to SQL Server by itself. Have you tried? It is in Data menu.

Save Excel sheet into SQL

Excel has a Get External Data ribbon bar in the Data tab where we can choose to import tables from SQL databases. This process worked out nicely for me. But my question is, is there any way to save this data back into SQL? Does Excel provide some API that facilitates the coding of such a function without parsing everything and doing it from scratch?
Thanks
It may not be the solution you are looking for, but I posted some VBA code a long while back that will take a range in Excel and convert it to XML and builds the SQL to put that data into a temp table in SQL Server. Here's a link if you are interested.
The easiest way to do this is to use the import function within SSMS. You can select which sheets to use, customise column mappings and so on. If creates an SSIS that you can then manipulate further if required. However that approach is a pull from Sql, not a push from Excel, if you want to do that you'd have to code some VBA to do it for you.
Non-programmatically:
http://office.microsoft.com/en-us/excel-help/connect-to-import-sql-server-data-HA010217956.aspx
Programmatically - I can only think of the OpenRowSet function in MSSQL:
http://www.mssqltips.com/tip.asp?tip=1540
http://www.sql-server-helper.com/tips/read-import-excel-file-p01.aspx
Using openrowset to read an Excel file into a temp table; how do I reference that table?

Resources