#region datagridview資料顯示到excel
///
/// 開啟excel並將datagridview控制項中資料匯出到excel
///
/// datagridview物件
/// 是否顯示excel介面
///
/// add com "microsoft excel 11.0 object library"
/// using excel=microsoft.office.interop.excel;
///
///
///
/// using system.io;
///
///
private void datagridviewtoexcel(datagridview dgv)
columntitle += dgv.columns[i].headertext;
}
sw.writeline(columntitle);
//寫入列內容
for (int j = 0; j < dgv.rows.count; j++)
if (dgv.rows[j].cells[k].value == null)
columnvalue += "";
else
columnvalue += dgv.rows[j].cells[k].value.tostring().trim();
}
sw.writeline(columnvalue);
}
sw.close();
mystream.close();
}
catch (exception e)
finally
}
}
#endregion
#region datagridview匯出到excel,有一定的判斷性
///
///方法,匯出datagridview中的資料到excel檔案
///
///
/// add com "microsoft excel 11.0 object library"
/// using excel=microsoft.office.interop.excel;
/// using system.reflection;
///
/// datagridview
從 DataGridView 匯出到 Excel
public sub exporttoexcel byval datagridview1 as datagridview if datagridview1.rows.count 1 then for i 0 to datagridview1.columncount 1 生成excel中列頭名稱 my...
datagridview 匯出Excel檔案
以datagridview 匯出excel檔案 public void exportexcel datagridview dgv microsoft.office.interop.excel.workbook workbook workbooks.add microsoft.office.inter...
sql 匯出到execl,匯出到記事本 txt
exec master.xp cmdshell bcp ptdata.dbo.tb users out e temp2.xls c q s www 75af6dac011 u sa p y ht 1987 這樣子是匯出整張表 exec master.xp cmdshell bcp select us...