can any give example on ("how to export excel and freeze panes in second row using asp.net c#")
How to export excel and freeze panes in second row using asp
Hi,
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ring ZhongRank #6,843 · 255 reputationPosted Dec 29, 2013, 9:24 PM EST
<1>here is the demo for freeze panes in the second row:
using Spire.Xls;
using System.Drawing;
namespace FreezePane
{
class Program
{
static void Main(string[] args)
{
//Load File
Workbook workbook = new Workbook();
workbook.LoadFromFile
(@"E:\Work\Documents\ExcelFiles\PartSalesInfo.xlsx");
Worksheet sheet = workbook.Worksheets[0];
//Freeze the Second Row
sheet.FreezePanes(3, 1);
//Save and Launch
workbook.SaveToFile("FreezePane.xlsx", ExcelVersion.Version2010);
System.Diagnostics.Process.Start(workbook.FileName);
}
}
}
download spire.xls from here:
http://spreadsheet.codeplex.com/
<2>how to export excel?
do you mean export from datatable(database) to excel? if so
Demo here:
//export datatable to excel
Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
sheet.InsertDataTable(t, true, 1, 1);
book.SaveToFile("insertTableToExcel.xls");
for detailed info here:
http://www.e-iceblue.com/Knowledgebase/Spire.XLS/Program-Guide/Data-Export-/Import-Export-Datatable-to-Excel-from-Database.html
Also dataset to excel:
http://www.c-sharpcorner.com/uploadfile/babu_2082/export-dataset-to-excel/default.aspx
Richard Porter34 reputationPosted Feb 19, 2015, 1:16 AM EST
// Load excel file. var excel = ExcelFile.Load(Server.MapPath("~/Book1.xlsx")); // Get active sheet. var sheet = excel.Worksheets.ActiveWorksheet; // Freeze second sheet's row. sheet.Panes = new WorksheetPanes(PanesState.Frozen, 0, 2, "A3", PanePosition.BottomLeft);// Export excel's data to DataTable DataTable table = sheet.CreateDataTable(new CreateDataTableOptions()); // Export excel file to client's browser. excel.Save(this.Response, "Book1.xlsx");