private bool ExportForExecl(object sender, DoWorkEventArgs e)
{
Microsoft.Office.Interop.Excel.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
Microsoft.Office.Interop.Excel.Workbook workbook = excel.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet); //生成一个workbook对象
Microsoft.Office.Interop.Excel.Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];//取得第一个 sheet
Object Nothing = System.Reflection.Missing.Value;
//公共属性
int rowHeight = 15;
int columnWidth = 2;
int fontSize = 12;
Color color = Color.FromArgb(218, 150, 148);
int beginIndex = 3;//开始行
try
{
foreach (System.Data.DataTable dt in dts)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Range range = null;// 创建一个空的单元格对象
DataRow dr = dt.Rows[i];
string tableName = dr["表名"].ToString();
string tableMemo = dr["表说明"].ToString();
string sheetName = tableMemo.IsNotNullAndEmpty() ? tableMemo : tableName;
if (sheetName.IsNotNullAndEmpty())
{
//sheet名是否有重复,有重复就在名字后面加序数
if (sheetNames.Keys.Contains(sheetName))
{
int m = sheetN
{
Microsoft.Office.Interop.Excel.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
Microsoft.Office.Interop.Excel.Workbook workbook = excel.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet); //生成一个workbook对象
Microsoft.Office.Interop.Excel.Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];//取得第一个 sheet
Object Nothing = System.Reflection.Missing.Value;
//公共属性
int rowHeight = 15;
int columnWidth = 2;
int fontSize = 12;
Color color = Color.FromArgb(218, 150, 148);
int beginIndex = 3;//开始行
try
{
foreach (System.Data.DataTable dt in dts)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Range range = null;// 创建一个空的单元格对象
DataRow dr = dt.Rows[i];
string tableName = dr["表名"].ToString();
string tableMemo = dr["表说明"].ToString();
string sheetName = tableMemo.IsNotNullAndEmpty() ? tableMemo : tableName;
if (sheetName.IsNotNullAndEmpty())
{
//sheet名是否有重复,有重复就在名字后面加序数
if (sheetNames.Keys.Contains(sheetName))
{
int m = sheetN