首页 最全的OLE操作Excel的完整代码

最全的OLE操作Excel的完整代码

举报
开通vip

最全的OLE操作Excel的完整代码最全的OLE操作Excel的完整代码 #include #include "Excel_2K_SRVR.h" //#include "ComObj.hpp" /*------------------------------------------------- //谨慎的思考310032649原创文章 //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 -...

最全的OLE操作Excel的完整代码
最全的OLE操作Excel的完整代码 #include #include "Excel_2K_SRVR.h" //#include "ComObj.hpp" /*------------------------------------------------- //谨慎的思考310032649原创文章 //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ void __fastcall TForm1::Button1Click(TObject *Sender) { AnsiString str1="asvasd";//要入库的数据 Variant ex,newxls,sh; try{ ex=CreateOleObject("Excel.Application");//启动Excel ex.OlePropertySet("Visible",(Variant)true);//使Excel启动后可见 //ex.OlePropertyGet("WorkBooks").OleProcedure("ADD");//新建一新工作薄(加上这一句,会有两个Excel窗口,同时关闭) //ex.OlePropertySet("Visible",(Variant)false);//使Excel启动后不可见 //ex.OlePropertySet("Windowstate",1);//Excel启动后窗体状态:1(xlNormal)正常显示(Excel上次关闭时是什么状态,启动后就是什么状态),2(xlMinimized)最小化(不是缩小到任务栏),3(xlMaximized)最大化 newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add");//①//使用ExcelApp的Exec 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 新建一有3个工作 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf 的默认工作薄 //newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add",1);//创建有单个工作表的工作簿 //newxls=ex.OlePropertyGet("workbooks").OleFunction("open", "c:\\123.xls");//打开已存在的文件,使用时可将上面关于新建①的那行屏蔽掉 sh=newxls.OlePropertyGet("ActiveSheet"); }catch(...){ ShowMessage("启动Excel出错,可能沒有安裝Excel"); return; } //Excel的警告提示: sh.OlePropertyGet("Application").OlePropertySet("DisplayAlerts",false);//关闭Excel的警告提示,如提示保存等 //sh.OlePropertyGet("Application").OlePropertySet("DisplayAlerts",true);//打开Excel的警告提示,如提示保存等 //选择工作表: //newxls.OlePropertyGet("Sheets", 2).OleProcedure("Select");//选择第二工作表 //sh = newxls.OlePropertyGet("ActiveSheet");//选择第二工作表 //重命名工作表: //sh.OlePropertySet("Name", "Sheet的新名字");//重命名当前工作表 //取得工作表总数: int nSheetCount=newxls.OlePropertyGet("Sheets").OlePropertyGet("Count");//取得工作表总数 Edit1->Text=nSheetCount; /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ //新建工作表并重命名: try{ Variant bef1,aft1; int count=ex.OlePropertyGet("sheets").OlePropertyGet("count"); aft1=ex.OlePropertyGet("sheets",count); ex.OlePropertyGet("sheets").OleProcedure("Add",bef1.NoParam() , aft1); sh = ex.OlePropertyGet("ActiveSheet"); sh.OlePropertySet("Name","增加的sheet的名字");//名字不能重复 }catch(...){ //ShowMessage ("There's something wrong with your Excel file./nPlease check it!"); } //指定状态栏显示的文本: //ex.OlePropertySet ("StatusBar","您好,请您稍等。正在查询!");//设置 //ex.OlePropertySet ("StatusBar", false);//还原成默认值 //指定标题:Exec窗口标题栏最左边显示的文本 //ex.OlePropertySet("Caption","查询系统"); //插入图片: sh.OlePropertyGet("Shapes").OleFunction("AddPicture","c:\\123.gif",false,true,sh.OlePropertyGe t("Range","B10").OlePropertyGet("Left"),sh.OlePropertyGet("Range","B10").OlePropertyGet("T op"),-1,-1);//插入图片 //使指定单元格里面的数字以文本形式存储: sh.OlePropertyGet("Cells", 2, 2).OlePropertySet("NumberFormatLocal", "@");//使指定单元格里面的数字以文本形式存储,可以省略 //使用下划线: //sh.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("Underline",true);//在所有单元格中使用下划线 //sh.OlePropertyGet("Cells",1,1).OlePropertyGet("Font").OlePropertySet("Underline",true);//在指定单元格中使用下划线 //使用删除线: sh.OlePropertyGet("Cells",i,1).OlePropertyGet("Font").OlePropertySet("Strikethrough",true);//在指定单元格中使用删除线 //使用斜体: //sh.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("Italic",true);//在所有单元格中使用斜体 //sh.OlePropertyGet("Cells",1,1).OlePropertyGet("Font").OlePropertySet("Italic",true);//在指定单元格中使用斜体 /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ //设置字体颜色: //sh.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("Color",RGB(0,0,255));//设置所有单元格的字体颜色 //sh.OlePropertyGet("Cells",1,1).OlePropertyGet("Font").OlePropertySet("ColorIndex",3);//设置指定单元格的字体颜色,这里为红色 //sh.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("ColorIndex",3);//设置所有单元格的字体颜色,这里为红色 //设置列宽度: //sh.OlePropertyGet("Columns",3).OlePropertySet("ColumnWidth",28);//设置第3列的列宽为28 //sh.OlePropertyGet("Columns").OlePropertySet("ColumnWidth",28);//设置所有列的列宽为28 //设置行高度: //sh.OlePropertyGet("Rows").OlePropertySet("RowHeight",28);//设置所有行的高度为28 //sh.OlePropertyGet("Rows",3).OlePropertySet("RowHeight",28);//设置指定行的高度为28 //设置字体: //sh.OlePropertyGet("Cells", 1, 1).OlePropertyGet("Font").OlePropertySet("Name", "隶 关于书的成语关于读书的排比句社区图书漂流公约怎么写关于读书的小报汉书pdf ");//设置第一行第一列单元格的字体 //sh.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("Name", "隶书");//设置所有单元格的字体 //字体大小: //sh.OlePropertyGet("Cells", 1, 1).OlePropertyGet("Font").OlePropertySet("Size",10);//设置第一行第一列单元格的字体大小为10号 //sh.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("Size",10);//设置所有单元格的字体大小为10号 //使用粗体: //sh.OlePropertyGet("Cells",1,1).OlePropertyGet("Font").OlePropertySet("Bold",true);//设置第一行第一列单元格的字体为粗体字 //sh.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("Bold",true);//设置所有单元格的字体为粗体字 //插入和删除行: //sh.OlePropertyGet("Rows", 1).OleProcedure("Insert");//在指定位置插入行 //sh.OlePropertyGet("Rows", 1).OleProcedure("Delete");//将指定的行删除 //设置单元格的数字显示格式: //sh.OlePropertyGet("Cells", 1, 1).OlePropertySet("NumberFormatLocal", "0.00%");//设置指定单元格格式为小数百分比 //sh.OlePropertyGet("Cells").OlePropertySet("NumberFormatLocal", "0.00%");//设置所有单元格格式为小数百分比 //sh.OlePropertyGet("Rows",1).OlePropertySet("NumberFormatLocal", "0.00%");//设置指定行单元格格式为小数百分比,当不加“,1”时为所有行 //sh.OlePropertyGet("Columns",1).OlePropertySet("NumberFormatLocal", "0.00%");//设置指定列单元格格式为小数百分比,当不加“,1”时为所有列 //sh.OlePropertyGet("Cells",1,1).OlePropertySet("NumberFormatLocal","#,##0.00");//指定单元格如果是数字就保留两位小数 //文本自动换行: //sh.OlePropertyGet("Cells", 1, 1).OlePropertySet("WrapText", true);//设置指定单元格的文本自动换行 //sh.OlePropertyGet("Cells").OlePropertySet("WrapText", true);//设置所有单元格的文本自动换行 //sh.OlePropertyGet("Columns",1).OlePropertySet("WrapText", true);//设置指定列的单元格的文本自动换行, 当不加“,1”时为所有列 //sh.OlePropertyGet("Rows",1).OlePropertySet("WrapText", true);//设置指定行的单元格的文本自动换行, 当不加“,1”时为所有行 /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ //指定单元格的合并: //String strRange ="A2:A3:C3";//指定合并的单元格的矩形范围 //sh.OlePropertyGet("Range", strRange.c_str()).OleFunction("Merge", false);//将指定的单元格合并 //sh.OlePropertyGet("Range", "A2:A3:C3").OleFunction("Merge", false);//将指定的单元格合并 //给单元格赋值: //sh.OlePropertySet("Cells","第&P 頁,共&N 頁");//给所有单元格赋值 sh.OlePropertyGet("Cells",1,1).OlePropertySet( "Value",str1.c_str());//给指定单元格赋值 //sh.OlePropertyGet("Rows",1).OlePropertySet("Value",1234);//给整个行的单元格赋值 //sh.OlePropertyGet("Columns",1).OlePropertySet("Value",1234);//给指定的整个列赋值 //从单元格中取值: //AnsiString abc=sh.OlePropertyGet("Cells",1,1).OlePropertyGet("Value");//取指定单元格的值 //选择单元格: //sh.OlePropertyGet("Cells").OleFunction("Select");//选择所有单元格 //sh.OlePropertyGet("Cells",3,3).OleFunction("Select");//选择指定单元格(指定的单元格获得焦点) /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ //区域操作: //sh.OlePropertyGet("Range","A1:A10");//创建区域对象 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Cells").OlePropertySet("Value",10);//给指定区域的单元格赋值 //sh.OlePropertyGet("Range","A1:A10").OlePropertyGet("Cells").OleFunction("Select");//选中指定区域的单元格 //sh.OlePropertyGet("Range","A1:A10").OlePropertyGet("Font").OlePropertySet("Name", "隶书");//设置指定区域中所有单元格的字体 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Font").OlePropertySet("Underline",tru e);//设置指定区域的所有单元格中使用下划线 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Font").OlePropertySet("Italic",true);//设置指定区域中所有单元格中使用斜体 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Font").OlePropertySet("Color",RGB(0, 0,255));//设置所有单元格的字体颜色 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Font").OlePropertySet("Size",10);//设置指定区域中所有单元格字体的大小为10号 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Font").OlePropertySet("Bold",true);//设置指定区域中所有单元格的字体为粗体字 //sh.OlePropertyGet("Range","A1:C10").OleProcedure("Insert");//在指定区域前面增加指定列的单元格,指定区域外不受影响 //sh.OlePropertyGet("Range","A1:C10").OleProcedure("Delete");//将指定的行删除 //sh.OlePropertyGet("Range","A1:C10").OlePropertySet("NumberFormatLocal", "0.00%");//设置指定区域中的所有单元格格式为小数百分比 //sh.OlePropertyGet("Range","A1:C10").OlePropertySet("WrapText", true);//设置指定区域中所有的单元格中的文本自动换行 //sh.OlePropertyGet("Range","A1:C10").OlePropertySet("ColumnWidth",28);//设置指定区域所包含的所有列的列宽为28 //sh.OlePropertyGet("Range","A1:C10").OlePropertySet("RowHeight",28);//设置指定区域所包含的所有行的高度为28 //sh.OlePropertyGet("Range","A1:C20").OlePropertySet("DirectDependents","sdasd");//将选定区域中所有含公式的单元格填充成指定值,"sdasd"可以替换成不加引号的TRUE等 //单元格中的数据计算: //sh.OlePropertyGet("Cells",5,6).OlePropertySet("FormulaR1C1","=SUM(R[-3]C:R[-1]C)");//竖排加法运算 //sh.OlePropertyGet("Cells",2,9).OlePropertySet("FormulaR1C1","=SUM(RC[-3]:RC[-1])");//横向加法运算 //sh.OlePropertyGet("Cells",5,8).OlePropertySet("FormulaR1C1","=SUM(R[-3]C[-2]:R[-1]C[-1]) ");//横竖向加法运算 //页眉页脚设置:打印预览才能看见 sh.OlePropertyGet("PageSetup").OlePropertySet("LeftHeader","sdfgs");//左上角页眉设置sh.OlePropertyGet("PageSetup").OlePropertySet("CenterHeader","sadfs");//中间页眉设置sh.OlePropertyGet("PageSetup").OlePropertySet("RightHeader","345s");//右上角页眉设置sh.OlePropertyGet("PageSetup").OlePropertySet("LeftFooter","234fasdf");//左下角页脚设置sh.OlePropertyGet("PageSetup").OlePropertySet("CenterFooter","第&P 页,共&N 页");//中间页脚设置(这里显示第几页,共几页) sh.OlePropertyGet("PageSetup").OlePropertySet("RightFooter","sd23");//右下脚页角设置 //边界设定:单位为:point , 一point = 1 / 72 inches //sh.OlePropertyGet("PageSetup").OlePropertySet("LeftMargin",15); //sh.OlePropertyGet("PageSetup").OlePropertySet("RightMargin",15); //sh.OlePropertyGet("PageSetup").OlePropertySet("TopMargin",15); //sh.OlePropertyGet("PageSetup").OlePropertySet("BottomMargin",15); //sh.OlePropertyGet("PageSetup").OlePropertySet("HeaderMargin",15); //sh.OlePropertyGet("PageSetup").OlePropertySet("FooterMargin",15); /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ //打印设定: //sh.OlePropertyGet("PageSetup").OlePropertySet("PrintTitleRows","$2:$2");//打印标题列 //sh.OlePropertyGet("PageSetup").OlePropertySet("PrintTitleColumns","$A:$A");//打印标题栏 //sh.OlePropertyGet("PageSetup").OlePropertySet("PrintArea","$A$1:$I$15");//打印范围 //sh.OlePropertyGet("PageSetup").OlePropertySet("PrintHeadings",false);//栏名列号 //sh.OlePropertyGet("PageSetup").OlePropertySet("PrintGridlines",false);//打印网格线 //sh.OlePropertyGet("PageSetup").OlePropertySet("PrintComments",xlPrintNoComments);//批注"无" //sh.OlePropertyGet("PageSetup").OlePropertySet("PrintQuality",300);//打印品质 //sh.OlePropertyGet("PageSetup").OlePropertySet("CenterHorizontally",true);//水平置中 //sh.OlePropertyGet("PageSetup").OlePropertySet("CenterVertically",false);//垂直置中 //sh.OlePropertyGet("PageSetup").OlePropertySet("Orientation",xlLandscape);//横向打印(xlPortrait 纵向打印) //sh.OlePropertyGet("PageSetup").OlePropertySet("Draft",false);//草稿品质 //sh.OlePropertyGet("PageSetup").OlePropertySet("PaperSize",xlPaperA4);//纸张大小 //sh.OlePropertyGet("PageSetup").OlePropertySet("FirstPageNumber",xlAutomatic);//起始页码 //sh.OlePropertyGet("PageSetup").OlePropertySet("Order",xlDownThenOver);//循栏打印(xlOverThenDown 循列打印) //sh.OlePropertyGet("PageSetup").OlePropertySet("BlackAndWhite",False);//储存格单色打印//sh.OlePropertyGet("PageSetup").OlePropertySet("Zoom",100);//缩放比例 //设定单元格背景色: //sh.OlePropertyGet("Cells",2,2).OlePropertyGet("Interior").OlePropertySet("ColorIndex",3);//设定指定单元格的背景色 //设定图样:xlGray50可以是1,2,3等数字 //sh.OlePropertyGet("Cells",4,2).OlePropertyGet("Interior").OlePropertySet("Pattern",xlGray50); //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Interior").OlePropertySet("Pattern",xlG ray50);//在指定区域设置图样 //设置单元格中的文字距左: //sh.OlePropertyGet("Cells",1,1).OlePropertySet("HorizontalAlignment",xlLeft);//设置单元格中的文字距左 //sh.OlePropertyGet("Cells",1,1).OlePropertySet("VerticalAlignment",xlCenter);//作用不明(垂直和水平居中?) //设置单元格中的文字距中: sh.OlePropertyGet("Cells",1,1).OlePropertySet("HorizontalAlignment",xlCenter);//设置单元格中的文字距中 //sh.OlePropertyGet("Cells",1,1).OlePropertySet("VerticalAlignment",xlCenter);//作用不明 //设置单元格中的文字距右: //sh.OlePropertyGet("Cells",1,1).OlePropertySet("HorizontalAlignment",xlRight);//设置单元格中的文字距右 //sh.OlePropertyGet("Cells",1,1).OlePropertySet("VerticalAlignment",xlCenter);//作用不明 /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ //工作表操作: //sh.OlePropertySet("Name", "Sheet的新名字");//重命名当前工作表 //sh.OleFunction("Delete");//删除当前工作表 //画单元格单条边框: //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertyGet("Item",xlEdgeLeft) .OlePropertySet("Weight",xlThin);//画单元格左边框 //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertyGet("Item",xlEdgeLeft) .OlePropertySet("LineStyle",xlContinuous);//画单元格左边框 //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertyGet("Item",xlEdgeRigh t).OlePropertySet("Weight",xlThin);//画单元格右边框 //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertyGet("Item",xlEdgeRigh t).OlePropertySet("LineStyle",xlContinuous);//画单元格右边框 //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertyGet("Item",xlEdgeTop). OlePropertySet("Weight",xlThin);//画单元格上边框 //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertyGet("Item",xlEdgeTop). OlePropertySet("LineStyle",xlContinuous);//画单元格上边框 //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertyGet("Item",xlEdgeBott om).OlePropertySet("Weight",xlThin);//画单元格下边框 //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertyGet("Item",xlEdgeBott om).OlePropertySet("LineStyle",xlContinuous);//画单元格下边框 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Borders").OlePropertyGet("Item",xlDi agonalDown).OlePropertySet("Weight",4);//将指定区域的单元格用粗实线划掉 //画单元格完整边框: //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Borders").OlePropertySet("linestyle",2 );//给指定区域的所有单元格加上边框,最后的数字:1=细实线框,2=短距虚线框,3=长距虚线框,4=点划线,5=双点划线,6=粗点划线 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Borders").OlePropertySet("weight",1);/ /给指定区域的所有单元格加上边框,最后的数字不大于4 //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Borders").OlePropertySet("colorindex" ,3);//给指定区域的所有单元格加上边框,最后的数字表示颜色 //sh.OlePropertyGet("Cells",11,2).OlePropertyGet("Borders").OlePropertySet("LineStyle",xlConti nuous);//给指定单元格四周加上实线边框 //去掉指定区域的边框: //sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Borders").OlePropertySet("linestyle",xl None);//去掉指定区域的边框 //画单元格单面边框参数说明: //xlDiagonalDown:绘制从左上到右下角的斜线 //xlDiagonalUp:绘制从左下到右上角的斜线 //xlEdgeBottom:画单元格下边框 //xlEdgeLeft:画单元格左边框 //xlEdgeRight:画单元格右边框 //xlEdgeTop:画单元格上边框 /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ try{ //sh.OleFunction("SaveAs", "c:\\123.xls");//保存工作簿,当文件已经存在时会有提示,如果不覆盖会出错,所以正式使用时要预先处理或拦截错误 //sh.OleFunction("SaveAs", WideString("c:\\"+ADODataSet1->FieldByName("creater")->AsString.Trim()+".xls"));//保存工作簿,当文件已经存在时会有提示,如果不覆盖会出错,所以正式使用时要预先处理或拦截 错误 //newxls.OleFunction("Close");//关闭表格 //ex.OleFunction("Quit");//退出Excel,释放OLE对象 }catch(...){ return; } //结束,如果没有如下代码,Excel线程直到应用程序退出才结束: Variant Axl,Workbook,AxSheet,nms,bef,aft; Axl=Unassigned; Workbook=Unassigned; AxSheet=Unassigned; bef=Unassigned; aft=Unassigned; nms=Unassigned; //ShowMessage("Well Done boy!");//弹出对话框 } //图表部分,备用:------------------------------ /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ 1) //开一个新的图表工作簿 Variant Chart; Chart = ex.Exec(PropertyGet("Charts")).Exec(Function("Add")); ex.Exec(PropertySet("Visible") << true); Chart.Exec(PropertySet("Type") << -4100); 2) //滚动图表 for(int nRotate=5; nRotate <= 180; nRotate += 5){ Chart.Exec(PropertySet("Rotation") << nRotate); } for(int nRotate = 175; nRotate >= 0; nRotate -= 5){ Chart.Exec(PropertySet("Rotation") << nRotate); } /*------------------------------------------------- //目前真正最全的OLE操作Excel的完整代码 //版本:2007.01.15.01 //C++Builder专家组www.3322ee.com原创文章 //转载请保留本版权信息,谢谢合作 --------------------------------------------------/ 3) //使用ExcelApp的Exec方法新建一新工作薄 newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add");//默认工作簿 //newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add",1);//单工作表 //newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add",2);//图表 //newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add",3);//宏表 //newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add",4);//国际通用宏表 //newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add",5);//与默认的相同 //newxls=(ex.OlePropertyGet("Workbooks")).OleFunction("Add",6);//工作簿且只有一个表
本文档为【最全的OLE操作Excel的完整代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_266065
暂无简介~
格式:doc
大小:58KB
软件:Word
页数:24
分类:互联网
上传时间:2019-05-29
浏览量:88