日期:2014-05-17 浏览次数:20470 次
public void Save(string sFilePath)
{
XlsDocument xls = new XlsDocument();
xls.FileName = sFilePath;
int colIndex = 0;
int rowIndex = 1;
Worksheet sheet = xls.Workbook.Worksheets.Add("Sheet1");
Cells cells = sheet.Cells;
// 表头
for (int i = 0; i < _fields.Length; i++)
{
if (_dataSource.Columns.Contains(_fields[i]))
{
colIndex++;
Cell cellHeader = cells.Add(rowIndex, colIndex, _titles[i]);
cellHeader.Font.Bold = true;
cellHeader.Font.ColorIndex = 4;
cellHeader.HorizontalAlignment = HorizontalAlignments.Left;
cellHeader.UseBorder = true;