Professional Documents
Culture Documents
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Excel = Microsoft.Office.Interop.Excel;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Windows.Forms;
using System.IO;
namespace WCFDbService
{
public class ReportDB
{
header.HorizontalAlignment = Excel.Constants.xlCenter;
header.Font.Bold = true;
header.Font.Size = 10;
//in tiu cho cc ct trong file excel
for (i = 0; i < socot; i++)
xlSheet.Cells[2, i + 2] = dt.Columns[i].ColumnName;
//dien cot stt
xlSheet.Cells[2, 1] = "STT";
for (i = 0; i < sohang; i++)
xlSheet.Cells[i + 3, 1] = i + 1;
//dien du lieu vao sheet
}
//autofit rng cho cc ct
for (i = 0; i < sohang; i++)
((Excel.Range)xlSheet.Cells[1, i + 1]).EntireColumn.AutoFit();
//save file
xlBook.SaveAs(f.FileName, Excel.XlFileFormat.xlWorkbookNormal, missValue,
missValue, missValue, missValue, Excel.XlSaveAsAccessMode.xlExclusive,
missValue, missValue, missValue, missValue, missValue);
xlBook.Close(true, missValue, missValue);
xlApp.Quit();
}
return result;
}
}
}