请问那有详细关于excel接口函数的例子!比如画出单元格,设置属性,合并单元格 up 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 画出单元格?单元格不是有吗?是给加边框吗?just like this: pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight); if (pBorder ) { pBorder ->PutLineStyle (varLineStyle); pBorder ->PutWeight (varWeight); pBorder ->PutColorIndex (varColorIndex); }设置属性,哪种属性?多得啦哈.合并单元格:like following: IndexToString(iLeft ,iTop,tszRange); _bstr_t leftRange =tszRange ; IndexToString(iRight ,iBottom,tszRange); _bstr_t rightRange =tszRange ; Excel::RangePtr pRange = pSheet ->GetRange (leftRange,rightRange); if (pRange) { pRange ->Merge (); } 画出单元格?单元格不是有吗?是给加边框吗?just like this: pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight); if (pBorder ) { pBorder ->PutLineStyle (varLineStyle); pBorder ->PutWeight (varWeight); pBorder ->PutColorIndex (varColorIndex); }设置属性,哪种属性?多得啦哈.合并单元格:like following: IndexToString(iLeft ,iTop,tszRange); _bstr_t leftRange =tszRange ; IndexToString(iRight ,iBottom,tszRange); _bstr_t rightRange =tszRange ; Excel::RangePtr pRange = pSheet ->GetRange (leftRange,rightRange); if (pRange) { pRange ->Merge (); } GetBorders()-> 没有GetItem() 它 Excel::BorderPtr pBorder ;"GetBorders()-> 没有GetItem() 它"什么意思?不明白. GetBorders() 返回值是IDispatch类型 它没有GetItem()成员函数你的pRange 是加的excel9.cpp里的Range 类定义的指针吗? Excel::BorderPtr pBorder ;我编译不过去,你加了那个头文件 just a simple win32 console project.not use mfc. :)#include <ole2.h>#include <stdio.h>#pragma warning (disable:4146)#pragma warning (disable:4192)#pragma warning (disable:4049)#import "d:\Program Files\Microsoft Office\Office\MSO9.dll"#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" no_namespace #import "d:\Program Files\Microsoft Office\Office\MSWORD9.OLB" rename("ExitWindows","_ExitWindows")#import "d:\Program Files\Microsoft Office\Office\excel9.olb" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") \ rename("DocumentProperties", "DocumentPropertiesXL") exclude("IFont","IPicture")char* IndexToString(int row, int col, char *strResult){ if (row < 1 || col < 1 ||IsBadWritePtr(strResult,sizeof(char*)) ) { return ""; } if(col > 26) { sprintf(strResult, "%c%c%d",'A'+(col-1)/26-1, 'A'+(col-1)%26, row); } else { sprintf(strResult, "%c%d", 'A' + (col-1)%26, row); } return strResult;}int main(int argc, char* argv[]){ VARIANT varItem; varItem.vt = VT_I4; varItem.intVal = 1; ::CoInitialize(NULL); CLSID clsid; CLSIDFromProgID(L"Excel.Application", &clsid); Excel::_ApplicationPtr pApp; pApp .CreateInstance (clsid,NULL); pApp ->PutVisible (0,VARIANT_TRUE); Excel::_WorkbookPtr pWorkbook = pApp ->GetWorkbooks ()->Add ();//->Open (OLESTR("E:\\EXCEL\\module.xls"));// Excel::_WorksheetPtr pSheet = pWorkbook ->GetWorksheets () ->GetItem (varItem); Excel::RangePtr pRange = pSheet ->GetRange(OLESTR("A1")); pRange ->Value2 = OLESTR("SOME"); Excel::InteriorPtr pInterior= pRange ->GetInterior (); varItem.intVal = 0xff0000; pInterior ->PutColor (varItem); TCHAR tszRange[32]; IndexToString(2,2,tszRange); _bstr_t bstrRange (tszRange); pRange = pSheet ->Range [bstrRange] ; Excel::BorderPtr pBorder ; _variant_t varLineStyle ; _variant_t varWeight; _variant_t varColorIndex; varLineStyle .vt = VT_I4; varLineStyle.intVal = 1;//excel::xlContinuous 1 varWeight.vt = VT_I4; varWeight.intVal = 2;//excel::xlThin 2 varColorIndex.vt = VT_I4; varColorIndex.intVal= 1; int iAlign = 15; if (iAlign & 1 )//左边的边框 { pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeLeft); if (pBorder) { pBorder ->PutLineStyle (varLineStyle); pBorder ->PutWeight (varWeight); pBorder ->PutColorIndex (varColorIndex); } pBorder = NULL; } if (iAlign & 2)//上边的边框 { pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeTop); if (pBorder) { pBorder ->PutLineStyle (varLineStyle); pBorder ->PutWeight (varWeight); pBorder ->PutColorIndex (varColorIndex); } pBorder = NULL; } if (iAlign & 4)//右边的边框 { pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight); if (pBorder ) { pBorder ->PutLineStyle (varLineStyle); pBorder ->PutWeight (varWeight); pBorder ->PutColorIndex (varColorIndex); } pBorder = NULL; } if (iAlign & 8 )//下边的边框 { pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeBottom); if (pBorder ) { pBorder ->PutLineStyle (varLineStyle); pBorder ->PutWeight (varWeight); pBorder ->PutColorIndex (varColorIndex); } pBorder = NULL; }#if 0 pSheet ->PrintPreview ();#endif ::CoUninitialize(); return 0;} 嘿嘿,你说能不能PrintPreview ()呢.just change #if 0 to #if 1. faint,你在stdafx.h里copy哪几个#include和#import,在对话框里放一个button,把main中间的东西copy出去.不就得了.不送我100分你就真不够意思.浪费我这么多口水.just a joke.not mind.haha.:) 我的msn是[email protected].公司不能上qq. :( 我哭,我的同学,我的... activex 无法验证发行者 dll之间共享注册表信息 关于网站自动登录浏览。 如何快速实现内存数据的块拷贝? 谁有iphlpapi.h和iphlpapi.lib给一份多谢 派生类生成对象会引起基类生成对象么. 两各对话框之间的拖动问题!(100分) 一个奇怪的link错误 小弟急需文件操作和线程管理方面方法技巧的资料,望各位英雄赐教 怎样在 RICHEDIT 中的光标位置上添加文本? 请问如何改变openGL中的坐标轴的方向 请教CSP方面的问题
just like this:
pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight);
if (pBorder )
{
pBorder ->PutLineStyle (varLineStyle);
pBorder ->PutWeight (varWeight);
pBorder ->PutColorIndex (varColorIndex);
}
设置属性,哪种属性?多得啦哈.
合并单元格:like following:
IndexToString(iLeft ,iTop,tszRange);
_bstr_t leftRange =tszRange ;
IndexToString(iRight ,iBottom,tszRange);
_bstr_t rightRange =tszRange ;
Excel::RangePtr pRange = pSheet ->GetRange (leftRange,rightRange);
if (pRange)
{
pRange ->Merge ();
}
just like this:
pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight);
if (pBorder )
{
pBorder ->PutLineStyle (varLineStyle);
pBorder ->PutWeight (varWeight);
pBorder ->PutColorIndex (varColorIndex);
}
设置属性,哪种属性?多得啦哈.
合并单元格:like following:
IndexToString(iLeft ,iTop,tszRange);
_bstr_t leftRange =tszRange ;
IndexToString(iRight ,iBottom,tszRange);
_bstr_t rightRange =tszRange ;
Excel::RangePtr pRange = pSheet ->GetRange (leftRange,rightRange);
if (pRange)
{
pRange ->Merge ();
}
"GetBorders()-> 没有GetItem() 它"什么意思?不明白.
你的pRange 是加的excel9.cpp里的Range 类定义的指针吗?
我编译不过去,你加了那个头文件
#include <stdio.h>
#pragma warning (disable:4146)
#pragma warning (disable:4192)
#pragma warning (disable:4049)#import "d:\Program Files\Microsoft Office\Office\MSO9.dll"
#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" no_namespace
#import "d:\Program Files\Microsoft Office\Office\MSWORD9.OLB" rename("ExitWindows","_ExitWindows")
#import "d:\Program Files\Microsoft Office\Office\excel9.olb" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") \
rename("DocumentProperties", "DocumentPropertiesXL") exclude("IFont","IPicture")char* IndexToString(int row, int col, char *strResult)
{
if (row < 1 || col < 1 ||IsBadWritePtr(strResult,sizeof(char*)) )
{
return "";
} if(col > 26)
{
sprintf(strResult, "%c%c%d",'A'+(col-1)/26-1, 'A'+(col-1)%26, row);
}
else
{
sprintf(strResult, "%c%d", 'A' + (col-1)%26, row);
}
return strResult;
}
int main(int argc, char* argv[])
{
VARIANT varItem;
varItem.vt = VT_I4;
varItem.intVal = 1;
::CoInitialize(NULL);
CLSID clsid;
CLSIDFromProgID(L"Excel.Application", &clsid); Excel::_ApplicationPtr pApp;
pApp .CreateInstance (clsid,NULL);
pApp ->PutVisible (0,VARIANT_TRUE);
Excel::_WorkbookPtr pWorkbook = pApp ->GetWorkbooks ()->Add ();//->Open (OLESTR("E:\\EXCEL\\module.xls"));//
Excel::_WorksheetPtr pSheet = pWorkbook ->GetWorksheets () ->GetItem (varItem);
Excel::RangePtr pRange = pSheet ->GetRange(OLESTR("A1"));
pRange ->Value2 = OLESTR("SOME");
Excel::InteriorPtr pInterior= pRange ->GetInterior ();
varItem.intVal = 0xff0000;
pInterior ->PutColor (varItem); TCHAR tszRange[32];
IndexToString(2,2,tszRange);
_bstr_t bstrRange (tszRange);
pRange = pSheet ->Range [bstrRange] ;
Excel::BorderPtr pBorder ;
_variant_t varLineStyle ;
_variant_t varWeight;
_variant_t varColorIndex; varLineStyle .vt = VT_I4;
varLineStyle.intVal = 1;//excel::xlContinuous 1 varWeight.vt = VT_I4;
varWeight.intVal = 2;//excel::xlThin 2 varColorIndex.vt = VT_I4;
varColorIndex.intVal= 1;
int iAlign = 15;
if (iAlign & 1 )//左边的边框
{
pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeLeft);
if (pBorder)
{
pBorder ->PutLineStyle (varLineStyle);
pBorder ->PutWeight (varWeight);
pBorder ->PutColorIndex (varColorIndex);
}
pBorder = NULL;
}
if (iAlign & 2)//上边的边框
{
pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeTop);
if (pBorder)
{
pBorder ->PutLineStyle (varLineStyle);
pBorder ->PutWeight (varWeight);
pBorder ->PutColorIndex (varColorIndex);
}
pBorder = NULL;
}
if (iAlign & 4)//右边的边框
{
pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight);
if (pBorder )
{
pBorder ->PutLineStyle (varLineStyle);
pBorder ->PutWeight (varWeight);
pBorder ->PutColorIndex (varColorIndex);
}
pBorder = NULL;
}
if (iAlign & 8 )//下边的边框
{
pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeBottom);
if (pBorder )
{
pBorder ->PutLineStyle (varLineStyle);
pBorder ->PutWeight (varWeight);
pBorder ->PutColorIndex (varColorIndex);
}
pBorder = NULL;
}
#if 0
pSheet ->PrintPreview ();
#endif
::CoUninitialize();
return 0;
}
不送我100分你就真不够意思.浪费我这么多口水.
just a joke.not mind.haha.:)
公司不能上qq. :( 我哭,我的同学,我的...