Copy prevention of Excel file - excel

There is excel file with complex mathematical model. How to prevent file coping from client machine to other machines? Client have to run Excel and type coefficients into equations, then Excel computes result.
I think about VB extension or macros which checks MAC of network card or value in Windows registry...

There is no way of securely sharing Excel w/o an intermediary application e.g. a WebApp.
If you have SharePoint host it via Excel services.
If you know ASP.NET or another Web language then write a simple calculator or use e.g. https://www.google.pl/search?q=excel+to+asp.net+converter&oq=excel+to&gs_l=serp.3.0.35i39j0l9.84291.85973.0.86694.10.9.0.0.0.0.595.1008.1j1j1j5-1.4.0....0...1c.1.51.serp..6.4.1005.XWeje4bO7mI

Related

SQL Server and Excel

I want to link an excel file to SQL Server 2014 whereby I can edit the file and the data gets updated on the server automatically.
Similar to what happens when you link sql server to Access whereas you can edit the data and the changes take effect in the server.
Thanks in advance
There is no out of the box solution for this. You can do this either of two ways:
Write a C# code which has a file watcher attached to the Excel file which uploads the Excel file using SSIS job to the database.
Create a scheduled SSIS job which imports the Excel file periodically.
Understanding the purpose would allow for greater elaboration.
This depends on the type of data you wish to edit.
For master data, if you have the Enterprise or Business Intelligence edition of SQL Server and Master Data Services set up, there is a plug-in for Excel:
https://msdn.microsoft.com/en-us/library/hh231024(v=sql.120).aspx
For transactional data, I would strongly advise against using Excel as a front-end and would recommend you to consider alternatives.
However, if you are compelled to go down this route, you can achieve this using VBA scripting and linking via a DAL (Data Access Layer) such as ADO.NET. Be aware that giving such power to your users could open up your system to sql injection attacks - only proceed so if you trust the users 100%. Another thing to take into consideration is validation checks - validation checks should be applied to every cell where data can be entered. More information can be found here:
https://support.microsoft.com/en-us/kb/316934

Refreshing Excel Data connection on a Windows Server

I am running an automated Data job on a windows server that outputs a SAS dataset everyday. On top of this, I have an Excel Report connected via Excel's Local Data Provider.
My problem is, that the Data Connection needs to be manually refreshed by a person with SAS installed on their PC. I have tried writing a piece of SAS code that opens the Excel file on the server and then triggers a piece of VBA that did the refreshing, before closing and saving. This works perfectly if I'm logged into the server. But it doesn't seem to work if nobody's signed in. I believe this has something to do with having an active user session.
UPDATE
The process that I use to connect to a local data source from Excel, looks like this:
Data Connection Wizard
Select SAS Local Data Provider from OLE DB Providers
Add the Route to my SAS Dataset as data source
Select My source table and create a Pivot Report
Is there any way to do something like this?
When you want to run Excel unattended, thus no interactive user is logged on, you can do this with a Windows service. You have to ensure some settings for Excel, as well as it is important how you start excel.
Be aware of Microsoft does not support, or even suggest you to do something like this. Excel is a client software, it is exactly the opposite of a piece of software that is easy to maintain running as as service. Read this excellent article Considerations for server-side Automation of Office about the topic. Even when a little old (talking about Office 2003) it is still state of the art.
Please consider these conditions:
You cannot use the System or Network account, you have to let the windows service running under an account that at least have excel started once. This cannot be done with the named ones (as they cannot be used as interactive users)
Excel has to be opened at least once with the user under with the windows service account will run. You'll have to configure dcom settings, open vba once to initialize it, and most probably set some settings like "trust vba model" to be able to programmatically access Excel
last but not least when starting Excel you have to start it with loading the user profile. The Process.Start method in c# allows exactly that by just setting a boolean value to true.
Doing it like this, Excel should just start fine and update data connection with the VBA.
You may want to implement that windows service in c#, as it is really easy, have a look: Creating a Basic Windows Service in C#.
When using c#, be aware of you have to correctly dispose interop objects, pretty good described in How to properly clean up Excel interop objects

Running Excel automation locally or on server

Wanted some opinions on which method is a better practice. We have a sales report that MUST be generated in a very specific format (down to the row colors and fonts).
I already have written a macro which pulls from our database and populates the entire workbook in about 15 seconds. The question is how should it be populated?
1) Process server-side: Users initiate the request on the intranet page. ASP.NET opens the workbook template, executes the macro and serves back the final sheet.
2) Process locally: Users download the blank template, run from their desktops which automatically connect to the database.
I like the first one because I can enforce the template, timing, users, and security of the data. But is running Excel automation on an internet web server recommended? I like the second option, but I'm afraid of losing standardization as template sheets begin floating around the company.
As for server side:
I highly.. HIGHLY.. recommend checking out the OpenOffice/LibreOffice XML format for spread sheets.
You can use the localc binary in headless mode to convert the XML file to XLSX or what have you. I use it to create PDF files instead of using ReportLab.
Alternatively here are some other projects that attempt to write to Microsoft formats directly:
http://pypi.python.org/pypi/xlrd
http://pypi.python.org/pypi/xlwt
As for client side:
If you expect the user to be only using Excel and not any other spreadsheet software then go ahead and use an ODBC data source. ODBC will have to be configured per user unless you use some fun VBScript to pull the data from an HTTP server every time it is loaded. There is also the option of making an XLS spreadsheet that simply holds the data and including it into an XLS document as well which would be both a server and client XLS requirement.
Go for server side. Makes information simple to archive and share and will most likely be multi-platform as well.
If you like to use your first option, then you want to avoid using VBA on an installed instance of Excel on the server. This is extremely resource intensive and does not scale well. Instead, if you are writing ASP.NET code, then you should try using the Microsoft Office Interop functionality that is built into the .NET framework. It should possible to adapt your existing VBA code to run under ASP.NET with some changes, but you will have a much more reliable product in the end.
Example Code
However, as #whardier points out in his response, if this were for a large scale or public site, the suggestions he makes would be much more suitable and would scale much further.

Using Excel spreadsheets with macros in backend of web application

I have an architectural nightmare lying before me and want to clear some details.
So, the question is as follows:
How can someone build a web application which uses some macros buried deep in the Excel spreadsheet as a back-end for computations?
The background:
My client has an Excel spreadsheet doing some calculation for him (so it's in some ways an Excel application). Now he is willing to have a WEB app using the same Excel spreadsheet as a back-end. Yep, it's as said: to have a web front-end doing queries to the macros in this Excel spreadsheet and getting calculated data back. No, I cannot look at the macros source and translate it to my target language, because the spreadsheet is password-protected from editing.
The main web server which better be left untouched is Apache. The target development language I most proficient with is PHP.
I have read the Microsoft Support article about Excel<->VB interoperability and question here about the Excel<->C# interoperability and concluded that the task is possible with the next dataflow:
Apache -> Some C#.NET / VB.NET app in backend as a relay -> my Excel spreadsheet -> back to relay -> Apache
but of course I think it's just horrible and I want some more sensible solution.
If the macros buried in the spreadsheet are VBA there is no clean way (AFAIK) of running the spreadsheet on a server.
There are some tools available that claim to be able to compile an excel spreadsheet including VBA into an executable that you could run on a server, but I have no experience of them so do not know which, if any, would suit your situation.

Use Excel for calculations in web app

I've inherited a large Excel spreadsheet that does some financial calculation magic using any number of simulation tables, and have been asked to write a web application as a front end. Now I could spend endless hours trying to figure out the sheet, or I could call the excel sheet from my web app. I seem to need the Office Primary Interop Assemblies, but do I also need to install office/excel on the web server? How can I handle multiple simultaneous requests to the same sheet? Is this approach even possible?
We have implement a project where we call several Excel spreadsheets from a web app.
We use Sharepoint Excel Services to do this. It has worked very well for us.
In our case our largest spreadsheet has over 300 input parameters, 1000 formuals and 50 results. This takes about 0.5 seconds, where most of that time is moving data in and out of excel services via a web service.
The main draw back in using Sharepoint Excel Services is the cost. However, in our case the saving in development time far out weighed the cost.
Excel is a desktop Application (and a very good one) and not designed for either multiple users or deployment in a web application. You might be able to cobble something together but you are likely to have to write a lot of code to manage the design features of a desktop app which are inadequacies in a web app.
You are better off trying to understand what the Excel workbook is doing and simulating it in code with the desired multi-user features in mind which must have been beneath the request for a web app. If you have access to the current users and/or author you should be able to document the requirement and you have the Excel workbook for you to test your algorithm against once you have understood it.
Best of luck.
Take a look at SpreadsheetGear. Ordinarily it is used to generate new spreadsheets, but it has a calculation engine for existing spreadsheets too. And unlike Excel, it was designed for a server environment.
Spreadsheet Gear
You can try SmartXLS for .net,it has a calculation engine for Excel workbook,it does not depend on Excel.
Not sure if this is appropriate to your task, but could you not import it into Google Spreadsheets to make it multi-user? If it is really complicated then I shouldn't think this will work, but might be worth a try.

Resources