Reading/Writing Excel sheet real time in C# - c#

Is there any free or purchased library or any API which allows me to update excel sheet while it is opened also.

I'm not certain of the nature of your project, but perhaps you could create an Office Add-In? I've had some very good experiences with Add-In-Express: http://www.add-in-express.com/add-in-net/index.php
If just creating an add-in isn't going to work for your application, consider writing a plugin that your application can communicate with to do the work for you behind the scenes.

If you want your Excel spreadsheet to be updated in real time, you have to develop an RTD which can be queried by Excel itself. Please refers to Microsoft documentation for that. Add-In express provides you excellent simplified API to develop that, we are using them and we are very happy with that.

There is no tool that can do that since the file is locked by the operating system.

With COM you should be able to drive a workbook that has been opened by the user.

Related

Writing to Excel using Microsoft.Jet.OLEDB.4.0 + Editing at the same time

I used the code described here to update an excel sheet using c#.
The problem is that the file gets locked and cannot be edited manually while it is being updated (unlike the example code, i am doing constant updates, realtime data feed)
Since it is a trading application, operators need to be able to add excel formulas while other cells are being updated.
I am new to this and open to switch to any other technology/architecture making this possible.
I am receiving a data feed and I just want to put in an excel file and update it in realtime while making it possible for sheets to be edited manually. I guess if the dll or add-in is called from within excel rather than oledb I would not have such a lock issue. So if there is any way to call my code from excel and not the other way round (not too painstaking if possible) I welcome any suggestion
EDIT : Solution
I finally opted for RTD Technology for Excel which is exactly what I was looking for.
MS Reference is 10 years old and VBA oriented but it gives the big guidelines and things did not change much since. I think I would not have made it through without Kenny Kerr's Artcile on the subject. Many thanks to him.
You will need to integrate into Excel itself... Excel offers an interface to achieve exactly what you describe... it is based on COM and called RTD (Realtime Data-Server) and gets called from Excel.
You have to build a COM component which adheres to the official spec...
Some usfeul links to get you started:
http://msdn.microsoft.com/en-us/library/aa140059%28v=office.10%29.aspx
http://msdn.microsoft.com/de-de/library/microsoft.office.interop.excel.rtd%28v=office.11%29.aspx
http://exceldna.codeplex.com/workitem/5902 (free library to ease the development)
http://www.add-in-express.com/docs/net-excel-rtd-servers.php (commercial library to ease the development)

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).

So I really can't use Excel Object Model to be used server-side?

I'm trying to develop a c#/asp.net application to extract data from a SQL server and have it formatted in an excel spreadsheet. I have been practicing with excel object model and recently stumbled upon this: http://support.microsoft.com/kb/257757 Considerations for server-side Automation of Office
From what I understand I really can't use Excel Object models? And if not what are other solutions/advice besides whats suggested in this article and 3rd party apps I can use?
From that article:
Microsoft does not currently recommend, and does not support,
Automation of Microsoft Office applications from any unattended,
non-interactive client application or component (including ASP,
ASP.NET, DCOM, and NT Services), because Office may exhibit unstable
behavior and/or deadlock when Office is run in this environment.
What this means is that Microsoft won't explicitly prevent you from trying (the licensing allows you to try.) However, if there is a problem, it's up to you to figure out how to fix it.
There is a better option:
Create Excel (.XLS and .XLSX) file from C#
This will allow you to create the file for download without having to use Excel automation on the server side.
I can recommend the SpreadsheetGear library, it has all the Excel functions in one managed dll:
http://www.spreadsheetgear.com/
You 'can' use Excel automation on the server side. However you will be breaching licences ,may run into security problems and generally experience other odd behaviour, especially if you have more than one user using it at a time. I would suggest that you dont do it.
If the data you want to write is simple enough just do it as a csv
If not and you really have to write a spreadsheet look for a 3rd
party component that writes excel files. I only know of one off
the
top of my head and thats Aspose.Cells, but that is quite
expensive.

SqlBulkCopy to upload Excel

If Im using SqlBulkCopy in .net 4.0 on a sql 2008 R2 database to upload excel data to the database, do I actually need Excel on the box hosting the site for this to work?
The reason I ask is I have a site up and running with this, and the hosting box has excel. The customer wants the site moved to a new box, this one doesnt have Excel and that bulk copy doesnt work. Other than the lack of excel there is no other difference.
thanks
If you are using the Microsoft Excel Object Library (COM Interop) to interface with Excel from .Net 4, then yes you need Excel installed as that is interfacing with the Excel object library.
What are your project references in C#?
Anything link to office automatiion would need taht part of office that is being automated. Also, if .Net 4 that objects may be referenced with the dynamic keyword.
Hard to tell exactly without knowing the project, references, and relevant code.
However, there are several third party libraries that allow interaction with Excel without having Excel installed. So, if you need to work without Excel, investigate using those.

Reading a Excel 2007 Spreadsheet in C#

I've done some googling and there seems to be a plethora of tools for reading excel 2007 spreadsheets using c#. I'd like to know which one performs best and is easy to use.
Frankly, it depends on if you have Excel installed on the machine.
If you have Excel installed, using Microsofts Office APIs is as quick and ( for the price ) painless as you are going to get. That said, if you don't have Excel installed, the question gets much trickier.
Also, note, if you are installing to a web server that is available to the world, using Microsoft's Office APIs often isn't actually legal, as the end user needs to have an office license for you to be legal. If this is the case, and you are developing for redistribution or internet deployment, make sure that the library you are considering has no dependencies on the Office APIs, as their redistribution isn't actually legal either. If you need to, for example, provide a viewer for people that don't have Excel installed, you can't legally use the Office APIs, nor can you use 3rd Parties that depend on that layer. Compliant libraries will make it clear in their description that they don't depend on Excel.
It depends what you're trying to do with the spreadsheet.
If you want to read tabular data, OleDB is the best option.
If you want to read formatting or specific cells, you should use a third-party component. (I can't recommend a specific vendor)
You should avoid using Excel's COM object model unless you want to interact with an open window or print a spreadsheet.
I've had pretty good results with Koogra.
Check the Open XML SDK. It includes a "Productivity Tool" that lets you walk through the structure of a document to help write your code as well.
I looked into the Open XML Format SDK about a year ago and it seemed like a good alternative that does not require Office installed.
I have used GemBox and the Microsoft Office APIs to read in spreadsheets. I have had success with both options but I tend to like GemBox a bit more. It is fast and simple to implement but comes with a price tag.

Categories

Resources