How to create excel sheet data directly from the .

2019-07-15 06:21发布

I want to create excel sheet from asp.net application using C# language.

please reply me how to create it and also if having source. I don't know how to create it.

Also I want drop down list in one of column. how we can do this.

Please reply me its urgent....

Regards, Girish

标签: c# asp.net excel
7条回答
可以哭但决不认输i
2楼-- · 2019-07-15 06:48

Another option (use the third party component) is SmartXLS.

查看更多
在下西门庆
3楼-- · 2019-07-15 06:54

Another option (no third party tools) is treat Excel Workbooks as ADO.NET Data Sources. Ref.: http://support.microsoft.com/kb/316934

查看更多
祖国的老花朵
4楼-- · 2019-07-15 07:01

try spread Sheet Gear third party component

http://www.spreadsheetgear.com/

查看更多
兄弟一词,经得起流年.
6楼-- · 2019-07-15 07:03

You can use Excel COM objects to create Excel sheets in ASP.NET.

Try this link.

查看更多
混吃等死
7楼-- · 2019-07-15 07:14

I'm using the ExcelPackage library which uses the OpenXML standard file format from Office 2007 and makes it really easy to create your own Excel sheets fro your C# or VB.NET app with little effort.

WORD OF WARNING: it has come to my attention (I didn't pay enough attention to that fact) that the ExcelPackage on CodePlex is actually licensed under a rather strict GPL license, which makes it virtually unusable for anyone but hobbyists. If you use it, you'll have to reveal all your source code of stuff produced with it.

It might look something like this:

using OfficeOpenXml;  // namespace for the ExcelPackage assembly

FileInfo newFile = new FileInfo(@"C:\mynewfile.xlsx"); 
using (ExcelPackage xlPackage = new ExcelPackage(newFile)) 
{
   ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets.Add("Tinned Goods");

   // write some titles into column 1
   worksheet.Cell(1, 1).Value = "Product";

   worksheet.Cell(4, 1).Value = "Peas";
   worksheet.Cell(5, 1).Value = "Total";

   // write some values into column 2
   worksheet.Cell(1, 2).Value = "Tins Sold";

   ExcelCell cell = worksheet.Cell(2, 2);
   cell.Value = "15"; // tins of Beans sold
   string calcStartAddress = cell.CellAddress;  // we want this for the formula
   worksheet.Cell(3, 2).Value = "32";  // tins Carrots sold

   worksheet.Cell(5, 2).Formula = string.Format("SUM({0}:{1})",
   calcStartAddress, calcEndAddress);
}

Totally free, available with source, doesn't require an installation of Office on the machine it runs on (e.g. your web server), no slow and messy COM interop - it just works like a charm! Very highly recommended.

Marc

查看更多
登录 后发表回答