Edit an excel file by means of C #

0

I want to edit an excel file, similar to an invoice, fill in the fields of the columns with the data in the textbox that I place, when I click on a button (Generate Fact.), I open the file with the data already added in the fields.

            //Inicie Excel y obtenga el objeto de la Aplicación.
            oXL = new Excel.Application();
            oXL.Visible = true;
            //Get a new workbook.
            oWB = (Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
            oSheet = (Excel._Worksheet)oWB.ActiveSheet;

In the part where it says ( // Get a new Woorkbok ) I want to replace is to open an existing Excel file.

    
asked by CarlosR93 09.01.2017 в 23:43
source

2 answers

0

You could use libraries based on open xml to access excel and complete the data in the cells you need

I would recommend you analyze the libraries

ClosedXML - The easy way to OpenXML

SpreadSheetLigth

The advantage of these libraries is that you do not need office installed on the pc to generate the excel (if to visualize)

I do not recommend that you use the Interop libraries since they are based on COM and are for problenma

    
answered by 10.01.2017 / 09:35
source
0

Without using the Microsoft interop library you can also use I know NPOI, which may be easier than using the open xml.

Here I attach the nuget link link

    
answered by 10.01.2017 в 11:31