|
首先需要CAXA 組件的許可,采用最新的CAXA組件版本(至少2009之後版本所帶的組件)。
對於電子圖板,可以參考組件自帶的例子,已經很夠了。
對於工藝給您幾行代碼可以做參考:
1.提取卡片表格內容
void CTestComDlg::OnButton2()
{
// TODO: Add your control notification handler code here
// 1.獲取輸入文件名,輸出文件名,模板文件
bool bGetInputName = false;
bool bGetOutPutName = false;
bGetInputName=GetInputFieName(1);
if(!bGetInputName)
return;
bGetOutPutName=GetOutPutName();
if(!bGetOutPutName)
return;
// 2.輸出到txt
HRESULT hRet;
CLSID clsid;
ICAPPInfo *pInterface=NULL;
ICAPPXmlInfo *pXmlInterface = NULL;
hRet=::CLSIDFromProgID(L"CAXAInfo.CAPPInfo",&clsid);
if(FAILED(hRet))
return;
hRet=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,IID_ICAPPInfo,(void **)&pInterface);
if(FAILED(hRet))
return;
CString CappFileName = sInputFileName;
CString TxtXmlFileName= sOutPutFileName;
CString sExtFilter = sFileExt;
VARIANT_BOOL ret;
BSTR BstrEbFileName,BstrTxtXmlFileName;
int iCardMask = 1|2|4|8|16;
BstrEbFileName=CappFileName.AllocSysString();
BstrTxtXmlFileName=TxtXmlFileName.AllocSysString();
if(sExtFilter == "xml")
{
pXmlInterface =(ICAPPXmlInfo*) pInterface;
hRet=pXmlInterface->InfoToXmlFile(BstrEbFileName,iCardMask,BstrTxtXmlFileName,&ret);
pXmlInterface = NULL;
}
else
{
pXmlInterface =(ICAPPXmlInfo*) pInterface;
hRet=pXmlInterface->InfoToTxtFile(BstrEbFileName,BstrTxtXmlFileName,&ret);
pXmlInterface = NULL;
}
if(FAILED(hRet))
{
::SysFreeString(BstrEbFileName);
::SysFreeString(BstrTxtXmlFileName);
HandError(pInterface,IID_ICAPPInfo);
pInterface->Release();
return;
}
::SysFreeString(BstrEbFileName);
::SysFreeString(BstrTxtXmlFileName);
pInterface->Release();
}
2.在單元格中反寫字符串
void CTest10Dlg::OnAddtexttocappbutton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString sCellContent="";
CString sTemp="";
sTemp=m_sColName+"^"+m_sInsTxtToCxp;//+"&"+m_sInsTxtToCxp;
CComBSTR bstPath,bstFilePath,bsCellContent;
bstFilePath = m_sFilePath.AllocSysString();
bsCellContent =sCellContent .AllocSysString();
bstPath = m_sImgPath.AllocSysString();
int iAlignMode = m_ComboxAlignMode.GetCurSel();
int iFillInMode = m_CheckFillInMode.GetCheck();
CComBSTR bstCardname,bstColumnName;
bstCardname = m_sCardName.AllocSysString();
bstColumnName = sTemp.AllocSysString();
VARIANT_BOOL bRet;
OnBtnOpenCxpfile();
if (NULL != g_pICappInfo)
{
CComQIPtr<ICAPPXmlInfo> spCappFillInfo = g_pICappInfo;
spCappFillInfo->WriteTxtInfoToCard(bstCardname,bstColumnName,m_iRowNum,&bRet);
}
OnBtnCloseCxpfile();
}
3.在單元格中反寫圖片
void CTest10Dlg::OnButtonAddimgtocxp()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CComBSTR bstPath,bstFilePath;
bstFilePath = m_sFilePath.AllocSysString();
bstPath = m_sImgPath.AllocSysString();
int iAlignMode = m_ComboxAlignMode.GetCurSel();
int iFillInMode = m_CheckFillInMode.GetCheck();
CComBSTR bstCardname,bstColumnName;
bstCardname = m_sCardName.AllocSysString();
bstColumnName = m_sColName.AllocSysString();
VARIANT_BOOL bRet;
OnBtnOpenCxpfile();
if (NULL != g_pICappInfo)
{
CComQIPtr<ICAPPXmlInfo> spCappXmlInfo = g_pICappInfo;
spCappXmlInfo->WriteImgToCard(bstPath,bstCardname,bstColumnName,m_iRowNum,iAlignMode,iFillInMode,&bRet);
}
OnBtnCloseCxpfile();
}
|
|