0

I would like to know how to edit existing excel file template by editing some of the cells, in ASP.NET using c#?

I have already tried using excel library by adding COM component for excel library. But this required excel to be installed on server. And it is creating some issues when multiple users working on same.

Is there any way to edit existing excel file using drivers instead of using excel library?

Thanks in Advance!!!

user829339
  • 1
  • 1
  • 1

3 Answers3

0

Yes. There are C# libraries available that you could use to read/write to excel files.

Look at this almost similar question (most answers are for Office 2007): Please suggest ways to manipulate Excel spreadsheet without using Excel object as web server does not have MS office installed

See the following answer and the rest of the thread of you're working with 2003 and prior versions of excel. Create Excel (.XLS and .XLSX) file from C#

Community
  • 1
  • 1
gideon
  • 19,329
  • 11
  • 72
  • 113
0

You can perform SELECT, INSERT and UPDATE statements on an Excel sheet using OleDb. For example, the following statement inserts an additional row into Sheet1, filling the column labeled MyText with the value Hello World!.

using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\my\\excel\\file.xls;Extended Properties='Excel 8.0;HDR=Yes'")) {
    conn.Open();
    OleDbCommand cmd = new OleDbCommand("INSERT INTO Sheet1 (MyText) VALUES (?)", conn);
    cmd.Parameters.AddWithValue("@mytext", "Hello World!");
    cmd.ExecuteNonQuery();
}

PS: You are right in not using Office automation in a web application. That's not an officially supported scenario.

Heinzi
  • 167,459
  • 57
  • 363
  • 519
0

You may try Aspose.Cells for .NET. This component allows you to create and manipulate Excel files without the need of the Microsoft Excel installed. Moreover, this component is a standard .NET assembly which can be used both on 32-bit and 64-bit systems on all Windows OS. You may also see the Aspose.Cells for .NET Documentation. The API is very simple.

Disclosure: I work as developer evangelist at Aspose.

Shahzad Latif
  • 1,408
  • 12
  • 29