Creating a C# program that works with an existing Excel Workbook - excel

firstly I'm not even sure if its even possible so i thought id ask
all research that i have done haven't given me the answers and info I need.
I need to create a VS Win forms program (using visual studio 2012) that interacts with a DB & AN EXCEL 2010 WORKBOOK?
can it be reasonably done?
the specifics are these
the excel 2010 workbook already exists and comprises 35 sheets/pages, BUT NOT ALL PAGES NEED TO BE USED IN THE PROGRAM only 12 do. it is a workbook for project management
the program works with button click events, that when pressed would open a specific page/sheet of the workbook. the user would then be able to fill in fields etc and save it
ideally also print it(Specific page) (from program and not excel directly) and obviously access it and amend or add to it from the Program time and time again
the workbook is a master workbook so every time a new project is created, the program would need to generate a new "instance" of the master workbook (the 12 pages)
each project and the "instance" of the workbook would need to be saved separately on the Hard Drive
this is/would be a client side stand alone application running on a laptop
is this possible? or highly complex?
and if so what are the relevant classes that would need to be imported into the project
or is it better/possible? to take the relevant pages ad make a new workbook inside of visual studio office node and make instances of it ??
at no point at all does data in the DB or Excel workbook need to be transferred to one another. they run separately but are part of the one program
any and all help would be appreciated

This is not a complex project, visual studio supports Microsoft Excel 12.0 Object Library. You can import the library and start using the events built in. It works great with excel. I have created numerous projects just like the one you've mentioned and had no problems so far.
Try this link

Related

Update VSTO Excel workbook without interfering with the Data itself

I built an Add-in for Excel using VSTO, and deployed it over...
now i have an updated version (where there are some new Toolbar Controls, a new column, and some bugs fixed in the behaviours).
my problem is that my client was working with the previous version, was filling his Data inside the sheet.
How can I Update the VSTO Add-in, and Migrate the Data ?
thanks for your help
Well it depends on how you created the add-in. An add-in is NOT coupled with any workbook (which is different to document level customization) unless you make it so.
Basically you just change your code, deploy a new version and your client will install it. When Excel is launched the new version will be used so if you have a button on Ribbon, the button now will use the new version.
If you, for any reason, make the add-in tightly coupled with a specific workbook (format) you'll have to deal with it.
So for example, if the new version is now expecting a new layout of data you'll either ask clients to change it manually or write a function that will do that for them.
Example: We have a VSTO Word add-in that does a lot of stuff, the add-in is using a template which has a version like (1, 2, 3, 4 ...) when we change the template (e.g. adding styles, addin shapes, removing shapes, etc.) we also maintain a recursive update method that is triggered on opening a document.
The method is checking the version of the template with the version hardcoded in the code, comparing and if the template version is older will trigger the update functionality (step by step, so from v1 to v2 then v2 to v3 and so on till it reach the latest version)
Hope that helps

Excel 2016 cannot access DDE server

I'm using Excel 2016 to access a DDE server (Rockwell Software's RSLinx Classic.) The DDE server is working correctly/can be accessed from other applications. The problem is trying to access it from Excel.
This is what is in my cell: =RSLinx|PS9TOPIC1!'N7:0'
The PS9TPIC1 topic is set up (and works) in RSLinx. RSLinx is up and running. But I get:
Remote data not accessible... Start application RSLINX.EXE?
Clicking Yes gets:
Cannot run 'RSLINX.EXE'. The program or one of its components is missing or corrupted
The program runs fine. I have ensured that RSLinx.exe is on the PATH (Double-checked the PATH for the running Excel using Task Manager.) It doesn't matter whether I have RSLinx running before starting Excel or have Excel try to launch it.
No, the option to "Ignore other applications that use Dynamic Data Exchange" is not checked for this document.
I tried running both RSLinx and Excel as "Administrator" with the same result.
Bringing up the help for data connections shows this:
Note: In an earlier version of Excel, you might have used Dynamic Data Exchange (DDE) in combination with the Step-by-Step Mail Merge Wizard in Word. Excel no longer supports DDE. If you'd like us to consider this feature for the next version of Excel, drop us a comment in the Excel Suggestion Box.
Try using an older Excel license.
I had the same problem, i already solved it. Just go to your project in the kepserver, open properties, and make sure enable the DDE conection to your server... Just that in my case. Good luck..
enter image description here

How can I set up an Access VBA library

I have some VBA code that I use across multiple projects - about 40 or so different data bases all use many of the same functions.
I try to use the same code in application each for consistency. Is there a way I can put all the code in one library and make it available to each data base? I'm getting tired of copying the code to a new data base every time I want to re-use it. I'm especially getting tired of maintaining it in multiple places when I want to change the functions.
I have the same question for Excel - can I create an Excel library and include it in all my workbooks?
If the VBA code works in VB6, you could create a DLL using VB6. The DLL would be a library of methods you could use across board just by referencing the DLL.
If it does not, you should create an Ms Access MDA file (add-in file) for all your reusable code, that can be added into any Access (or probably Excel) project.
Create one or many excel's per project, save those as *.xla. (Excel Add-In)
Go to your Excel Options and configure to load automatically those add-ins or thru VBA in your workbooks.
Using VBA Automation:
Application.AddIns.Add(XLA_Path)

Exporting data to existing Excel file

I have a system with an Excel spreadsheet template file which is used for invoicing. I would like the user to be able to click a button on an Xpage, which will then open the spreadsheet and enter the latest invoicing data in Excel. I don't mind if Excel is either the application on their machine or on the server, but my preference would be the application locally on their machine.
I've looked into Xagents, as I feel this is probably the answer. I know they can be used to create Excel but I have not been able to locate any mention of opening an Excel file, and entering data into specific cells.
Is this possible?
EDIT: you can use Apache POI for editing and creating Microsoft Office documents. This is a java project which gives you a handle to office documents and this can be used using java.
A good starting point can be the blog of Christian Guedemann from webgate:
http://guedebyte.wordpress.com/2012/09/17/documents-and-spreadsheets-with-xpages-building-the-kernel-part-ii/
(end of edit)
The only way I KNOW and tried to write data from Notes to Excel is exporting the data to an HTML page and setting the Content Type accordingly (e. g. as described here (there are a lot more resources available for taht):
http://www.dominoguru.com/pages/developer2010_xpagexlsexport.html
I am not sure if this is of help but it seems that this project can help you:
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=ZK%20Spreadsheet%20for%20XPages
As far as I can see this project can load Excel files from XPages - and then it should also be possible to edit the files.
Besides that the only solution I can think of is a Notes Agent that is called from the XPage. This agent can then run in background and do all the excel stuff. After running, the XPage can show a link to the Excel file. Actually this is the solution I would consider to implement - but maybe others step in with better answers here.
You don't want to introduce a dependency on Excel in your application -- wouldn't work with an iPad front-end. Rather have a look at the ZK Spreadsheet, it will fulfill your needs.
However if you have to have Excel, then you need a roundtrip solution: load the Excel from an URL (probably generated by an XAgent (?) and save it back. The saving back part is the tricky one. Normal HTTP doesn't allow that. What you need there is a webDAV capable server. Watch out for a project on OpenNTF soon (just clearing IBM legal) that provides webDAV.
However the ZK Spreadsheet looks much better for your needs.
I have a sample database at the following URL --> http://www.nnsu.com/nnsusite.nsf/%24%24OpenDominoDocument.xsp?documentId=B65507CB2DE15B3286257986005F061D&action=openDocument
Download the APCC.nsf. This will allow you to create/read a new EXCEL spreadsheet and then stream the resulting file to the requesting browser. There is not need to have EXCEL or office installed on the Server.
THe examples create a new workbook, but you can also store a "template" on the server or in a notes document and use it as a starting point and then save it to a document or stream it to the requesting browser.
With Apache POI you can read/write to a spreadsheet using data from the notes document the process is initiated from.

ssis excel source cannot acquire connection manager at DESIGN time

I have an SSIS (super)package that consists of several (about) 40 packages, each of which has several data flow tasks, most of them loading some excel data to a sqlserver database. So I have several excel source connection managers, one per excel file.
This has always worked fine until recently : I have to change an excel source in one of my packages (a column was added in the excel which has to be loaded in the destination sqlserver table) but I cannot edit the excel source in SSIS : when I click on "columns" I get an error box "DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER". So this is a design time issue, not a run time problem. I've seen a question like this one on stackoverflow but no answer. Anyone has an idea ?
I' ve already removed office 2007 and reinstalled office 2003 on my machine, but this didn't help
it has nothing to do with 64bit mode, which I've read about here
Is there some limit on the number of connection managers in ssis ?
Most of my connection managers were created with copy/paste and hence they have the same Id, although they point to different excel files. Could this be a problem ?
I should also mention that the package runs without any problems, so it's only "editing/changing" the package that doesn't work. For the moment I circumvent this problem by disabling the data flow that should change and by replacing it with a sql statement that hardcoded inserts the data from the excel into the destination table.
Maybe another intersting thing to mention : I can create a new package and add and change excel sources without problems, but then again, when I try to copy this excel source in my package, I cannot edit it.
Did you try to check the advanced options on the Source Connection?
Right click on the component and select "Show Advanced Editor..."
Select the column mappings tab and press the Refresh button.
This should point out that the XLS connection has some additional columns or that the file that you are pointing at, cannot be pre-validated at runtime.
M.
I'm not sure if this will work but try the Work Offline option in the SSIS menu in BIDS/VS. What this should do is not validate the connection before you edit the component. It might be able to get you into the component.

Resources