Getting error while writing output to Microsoft Excel programmatically - c#

I developed a winforms application using C# in .NET 4.0, in which end user selects an input Excel file. The program then generates an output Excel file with extra cells based on business logic of my application.
After selecting the input file and run my application, If i open any other excel sheets on my machine, then i see the output excel file being still written in Read Only mode and if i close the opened excel file then my application is throwing an error.
How to stop the read only excel sheet getting opened before the entire output is completely written?

Related

Can I build the vsto project in excel file

I have faced the following problem: if I write an extension in Visual Studio for Excel file, it saves as the .vsto file in the same location and then uploads in the Excel file on run. But I need .vsto file to be automatically uploaded, when the Excel file starts to execute, and not visible to a person, to whom I will pass the excel file.
Is there any way to do this? I want to place USB-key checking code in the VSTO workbook project (Excel file will be unprotected and opened only if there is a USB-key in the USB-port)
In case you need further clarifications, please do not hesitate to ask in this thread
There is no support in VSTO for embedding your code inside an Excel workbook.
The easiest way of embedding code in a workbook is by using VBA.
Otherwise you would need to find a way of forcing your VSTO code and the workbook to be in the same location.

How to programmatically restore the XLS file that was modified by a thirdparty tool

We are in the process of migrating the documents from AppXTender ( a EMC Documentum tool ) to another system.
I took a XLS file from AppXtender physical store ( the tool have renamed the .XLS file to .BIN ) and I knew its an excel file I tried renaming it to .XLS but the file is not opening as excel.
I learnt that the file is been modified by the AppXtender with some content like, "FFL 1.0 followed by the original file name.XLS".
When I open the excel in a notepad I could see this in the first line and there are couple of more lines with some text like "Embedded" and with some number.
If I manually remove those lines and save the file and still the file is not opening as excel.
What are these custom texts? how do i programmatically (C#) remove them from the excel file and restore as the proper excel file?
Thanks!
Karthik

Accessing an excel Project from A Winform Project in same Solution

I am trying to open an excel project in my Solution from a Winform Application. Please note:
Winform is my starting Project.
I can add Winform Reference in Excel but I can not add Excel Reference in Winform Project.
As I mentioned I cant find Excel Project in ADD REFERENCE>SOLUTION of Winform project. I also cant add it manually (Invalid dll or COM file Error!).
Any idea?
To open up excel you can use this:
Process.Start("excel.exe"); // or the real path of excel
And to have it open up with a certain worksheet, you could pass as an argument the path of the file:
Process.Start("excel.exe \"c:\My Folder\book1.xlsx\"");
i think iam not really getting what you mean but if you need to open the excel file with one click in the app
and you dont want to write the path of the excel file (may be because you want you app portable)
so the answer is to 1- put the excel file anywhere in the project folder
2- add existing item (. filter) and select the excel file
3-change the properties of the excel file
build action: resource
Copy to output directory:copy always
4-open the properties of the solution and click resources the drag the file and drop it
5-use the (using system.reflection & using system.io & using system.resources)
then write the code like this
string sPath = Path.GetTempFileName();
File.WriteAllBytes(sPath, Properties.Resources.excel File name here);
then take that (spath) and use it as your path so then you can change the project location with the excel file inside it and it will still be working without writing a constant path for it

Opening a MS .dot file through ASP.Net application

I have an application that when run in debug on my local machine has no problem opening this .dot file. But I've copied my application to a live server and when testing the app I get the following error message when trying to open the .dot file. This file is generated on a button click event and copies information from the system and pastes it into bookmarked sections on the template. The error is-
"ERROR: Cannot generate call sheet - Word was unable to read this document. It may be corrupt. Try one or more of the following: * Open and Repair the file. * Open the file with the Text Recovery converter."
The server has MS Word 2007 installed. Has anyone ever experienced this before, or are there any known workarounds that will correct this for me?

Is there any Open source Library to generate and edit .xls and .ppt file?

My task is to extract information from ppt file and compare with another ppt file. I have to use windows platform so i used excel and powerpoint's COM object.
After developing and testing the code in my computer when i exported the file into another computer it just failed. I started to debug in that file, and surprisingly debug was successful from first to last but as soon as click on the executable it fails.
I am totally *ucked up now cause inspite of updating excel dll files into those computers (which will serve the com support) it's not working. In every pc it gives different error message. I don't wanna work COM object anymore. It *ucks.
Can anyone suggest me any open source alternative in which i can read and extract information from Excel and Powerpoint files (both 2003 and 2007 format) ???
My preferred language is c# ........I got an paid solution (aspose) but i don't wanna go for that.
Any help will be appreciated. Just suggest me how can i deal with office files assuming ms office is not installed in my computer.
NPOI works well for Excel; I only know to use the built in, MS object library for PPT files.

Categories