如果具体到查询结果呢?查询具体到某一个人的信息输出到特定表格Excal中
急求
谢谢
C#, 把access数据导出成excel表格
答案:2 悬赏:0 手机版
解决时间 2021-04-08 19:30
- 提问者网友:临风不自傲
- 2021-04-08 02:27
最佳答案
- 五星知识达人网友:拜訪者
- 2021-04-08 03:08
添加一个引用(micros excel),然后添加如下代码:
Microsoft.Office.Interop.Excel.ApplicationClass myexcel = new Microsoft.Office.Interop.Excel.ApplicationClass();
myexcel.Visible = true;
if (myexcel == null)
{
MessageBox.Show("无法启动excel");
return;
}
myexcel.Application.Workbooks.Add(true);
int rowscount = this.dataGridView1.RowCount;
int colcount = this.dataGridView1.ColumnCount;
for (int i = 0; i < colcount; i++)
{
myexcel.Cells[1, i + 1] = this.dataGridView1.Columns[i].HeaderText;
}
for (int i = 0; i < rowscount; i++)
{
for (int j = 0; j < colcount; j++)
{
myexcel.Cells[i + 2, j + 1] = this.dataGridView1[j,i].Value.ToString();
}
}
Microsoft.Office.Interop.Excel.ApplicationClass myexcel = new Microsoft.Office.Interop.Excel.ApplicationClass();
myexcel.Visible = true;
if (myexcel == null)
{
MessageBox.Show("无法启动excel");
return;
}
myexcel.Application.Workbooks.Add(true);
int rowscount = this.dataGridView1.RowCount;
int colcount = this.dataGridView1.ColumnCount;
for (int i = 0; i < colcount; i++)
{
myexcel.Cells[1, i + 1] = this.dataGridView1.Columns[i].HeaderText;
}
for (int i = 0; i < rowscount; i++)
{
for (int j = 0; j < colcount; j++)
{
myexcel.Cells[i + 2, j + 1] = this.dataGridView1[j,i].Value.ToString();
}
}
全部回答
- 1楼网友:毛毛
- 2021-04-08 04:20
upload.asp 上传文件 if (top.location==self.location) { top.location="index.asp" } -------------------------------------- -------上传并且写入库----------- readxls.asp execl数据导入 120000 then %> alert("您选择的文件过大!"); wind...
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯