sql server 2000中的表导入EXCEL中,EXCEL的格式是固定好的,只要向其中填充数据即可,大家帮忙看看吧
解决方案 »
- Fatal error encountered during command execution.错误
- 这个帖子不给分 里面的给分
- 如何把XmlTextWriter中的数据导出一个xml文件
- 求一小算法~
- 怎样得到当前文件的绝对路径
- DragDrop 事件
- 为什么我调用OleDbDataReader.Close()和OleDbConnection.Close()的时候,程序就死了,不响应任何消息?
- 怎样使Form3窗体在最前面显示?
- 关于C#的动态数组
- c# 根据合计数,由随机函数生成加数
- Microsoft .NET Framework SDK v2.0怎么没有像SDK v1.1版那样的帮助文档?
- C#调用存储过程反回值的问题,请各位帮帮忙!
Excel.Workbook ThisWorkbook = null;
Excel.Worksheet ThisSheet = null;ThisApplication = new Excel.Application();
ThisApplication.ScreenUpdating = false;
ThisApplication.Visible = true;ThisWorkbook = ThisApplication.Workbooks.Add(System.Type.Missing); ThisSheet = (Excel.Worksheet)ThisWorkbook.Sheets[1];for (int y = 0; y < nds.Count; y++)
{
XmlNode xnd = nds.Item(y);
((Excel.Range)ThisSheet.Cells[y + 4, 2]).FormulaR1C1 = xnd.Attributes["AA"].Value;
((Excel.Range)ThisSheet.Cells[y + 4, 3]).FormulaR1C1 = xnd.Attributes["BB"].Value;
}
using Office = Microsoft.Office.Core;
{
if (null != ThisWorkbook)
{
ThisWorkbook.Saved = true;
}
if (null != ThisApplication)
{
ThisApplication.ScreenUpdating = true;
ThisApplication.DisplayAlerts = false;
ThisApplication = null;
}
}
ThisWorkbook = ThisApplication.Workbooks.Open(FilePath, System.Type.Missing, true,
System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing,
System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing,
System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing); ThisSheet = (Excel.Worksheet)ThisWorkbook.Sheets[1];
ThisSheet.Cells.Font.Size = 10;
ThisSheet.Cells.NumberFormatLocal = "@";
ThisSheet.Cells.WrapText = true; //设置列宽
((Excel.Range)ThisSheet.Columns["A:A", System.Type.Missing]).ColumnWidth = 0.85;
((Excel.Range)ThisSheet.Columns["B:B", System.Type.Missing]).ColumnWidth = 17.5;
((Excel.Range)ThisSheet.Columns["C:C", System.Type.Missing]).ColumnWidth = 10.5;
((Excel.Range)ThisSheet.Columns["D:D", System.Type.Missing]).ColumnWidth = 38.5;((Excel.Range)ThisSheet.Cells[3, 2]).FormulaR1C1 = "疏影横斜水清浅";
((Excel.Range)ThisSheet.Cells[3, 3]).FormulaR1C1 = "暗香浮动月黄昏";
这些格式在Excel里可以录制宏获得
从 .NET 开发人员的角度理解 Excel 对象模型