从一个excel复制到另外一个excel
2009-10-21 12:02
267 查看
Excel.Range m_objRange = null;
wbs.Open(source_path, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
//進行數據導出的主要代碼斷。
wb = (Excel.Workbook)wbs.get_Item(1);
Excel.Sheets st = wb.Worksheets;
//開始寫入日期
sheetdatetime = (Excel.Worksheet)st.get_Item(1);
for (int i = 1; i <= ds_datetime.Tables[0].Rows.Count; i++)
{
sheetdatetime.Cells[1, i] = ds_datetime.Tables[0].Rows[i - 1][0];
}
////更新數據
//exe_GDS_GenReport_procedure(customer, conn, flag[1]);
//System.Runtime.InteropServices.Marshal.ReleaseComObject(sheetdatetime);
//開始數據的錄入與表的生成
ds_part = get_part_target(conn);
//產生相應的表后同時對連個summary表進行操作。
ww_Summary_sheet = (Excel.Worksheet)st.get_Item(2);
regional_Summary_sheet = (Excel.Worksheet)st.get_Item(3);
int i_region_asl = 4, i_region_esl = 446, i_region_china = 868, i_region_apcc = 1290, i_region_japan = 1712, i_region_ww = 2134;
int i_ww_top = 3;
int base_count=0;
//ds_Rport_data = get_Report_data(conn);
Excel.Workbooks work_base=null;
Excel.Workbook wb_Base=null;
Excel.Worksheets st_Base=null;
Excel.Sheets sht_base = null;
Excel.Range range_Get = null;
for (int i = 0; i < ds_part.Tables[0].Rows.Count; i++)
{
if (i >= Ubound && i < 420)
{
//spilt the Excel
if (i == Ubound)
{
wbs.Open(replace_Goalpath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);//不同excel用一个workbook打开,另外声明一个exce.application对象那会一起线程异常错误
wb_Base = (Excel.Workbook)wbs.get_Item(2);
sht_base = wb_Base.Worksheets;
sheetCopy = (Excel.Worksheet)sht_base.get_Item(1);
for (int k = 1; k <= ds_datetime.Tables[0].Rows.Count; k++)
{
sheetCopy.Cells[3, k+4] = ds_datetime.Tables[0].Rows[k - 1][0];
}
}
sheetCopy1=null;
sheetCopy = (Excel.Worksheet)sht_base.get_Item(base_count + 1);
sheetCopy.Copy(sheetCopy,Type.Missing);
sheetCopy1 = (Excel.Worksheet)sht_base.get_Item(base_count + 1);
sheetCopy1.Cells[1, 4] = ds_part.Tables[0].Rows[i][0];
sheetCopy1.Cells[3, 4] = ds_part.Tables[0].Rows[i][1];
sheetCopy1.Name = ds_part.Tables[0].Rows[i][0].ToString();
wbs.Open(source_path, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
//進行數據導出的主要代碼斷。
wb = (Excel.Workbook)wbs.get_Item(1);
Excel.Sheets st = wb.Worksheets;
//開始寫入日期
sheetdatetime = (Excel.Worksheet)st.get_Item(1);
for (int i = 1; i <= ds_datetime.Tables[0].Rows.Count; i++)
{
sheetdatetime.Cells[1, i] = ds_datetime.Tables[0].Rows[i - 1][0];
}
////更新數據
//exe_GDS_GenReport_procedure(customer, conn, flag[1]);
//System.Runtime.InteropServices.Marshal.ReleaseComObject(sheetdatetime);
//開始數據的錄入與表的生成
ds_part = get_part_target(conn);
//產生相應的表后同時對連個summary表進行操作。
ww_Summary_sheet = (Excel.Worksheet)st.get_Item(2);
regional_Summary_sheet = (Excel.Worksheet)st.get_Item(3);
int i_region_asl = 4, i_region_esl = 446, i_region_china = 868, i_region_apcc = 1290, i_region_japan = 1712, i_region_ww = 2134;
int i_ww_top = 3;
int base_count=0;
//ds_Rport_data = get_Report_data(conn);
Excel.Workbooks work_base=null;
Excel.Workbook wb_Base=null;
Excel.Worksheets st_Base=null;
Excel.Sheets sht_base = null;
Excel.Range range_Get = null;
for (int i = 0; i < ds_part.Tables[0].Rows.Count; i++)
{
if (i >= Ubound && i < 420)
{
//spilt the Excel
if (i == Ubound)
{
wbs.Open(replace_Goalpath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);//不同excel用一个workbook打开,另外声明一个exce.application对象那会一起线程异常错误
wb_Base = (Excel.Workbook)wbs.get_Item(2);
sht_base = wb_Base.Worksheets;
sheetCopy = (Excel.Worksheet)sht_base.get_Item(1);
for (int k = 1; k <= ds_datetime.Tables[0].Rows.Count; k++)
{
sheetCopy.Cells[3, k+4] = ds_datetime.Tables[0].Rows[k - 1][0];
}
}
sheetCopy1=null;
sheetCopy = (Excel.Worksheet)sht_base.get_Item(base_count + 1);
sheetCopy.Copy(sheetCopy,Type.Missing);
sheetCopy1 = (Excel.Worksheet)sht_base.get_Item(base_count + 1);
sheetCopy1.Cells[1, 4] = ds_part.Tables[0].Rows[i][0];
sheetCopy1.Cells[3, 4] = ds_part.Tables[0].Rows[i][1];
sheetCopy1.Name = ds_part.Tables[0].Rows[i][0].ToString();
相关文章推荐
- Excel VBA 从一个工作簿查找另一个一个工作簿中的一些内容复制到另外一个工作簿
- 应用db link 把ORACLE 数据库中的表复制到另外一个数据库,也可以把表中的数据从一个库复制到另外一个库的表
- POI 复制excel一行到另外一个sheet页(修改)
- python把文件从一个目录复制到另外一个目录,并且备份
- 使用db link 把ORACLE 数据库中的表复制到另外一个数据库,也可以把表中的数据从一个库复制到另外一个库的表
- Java快速从一个文件夹复制到另外一个文件夹
- SQL SERVER 将表包括内容从一个数据库复制到另外一个数据库内
- oracle 从一个表复制、更新数据到另外一个表
- 从一个表向另外一个表复制行
- 把xib文件从一个项目复制到另外一个项目,里面内容变透明的问题
- sql server从一个数据库复制一张表到另外一个数据库
- 批处理 把文本中指定的文件从一个目录复制到另外一个目录
- android 嵌套 apk 从一个apk启动另外一个apk
- excel表格项等于另外一个表各项,并且空表项不显示0
- Ubuntu下将一个文件从一个目录复制到另一个目录中
- SQL语句 怎么把一个表的数据复制到另外一个表里面
- 目录下指定类型的文件复制到另外一个目录
- MFC从一个对话框向另外一个对话框发送消息
- 查询从一个表中返回所有记录不在另外一个表中的结果集的方法
- Java复制一个目录及其子目录的文件到另外一个目录