MyExcel.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. #include "stdafx.h"
  2. #include "MyExcel.h"
  3. CMyExcel::CMyExcel()
  4. {
  5. strFilePath=_T("");
  6. }
  7. CString CMyExcel::GetAppPath()
  8. {
  9. char lpFileName[MAX_PATH];
  10. GetModuleFileName(AfxGetInstanceHandle(),lpFileName,MAX_PATH);
  11. CString strFileName = lpFileName;
  12. int nIndex = strFileName.ReverseFind ('\\');
  13. CString strPath;
  14. if (nIndex > 0)
  15. strPath = strFileName.Left (nIndex);
  16. else
  17. strPath = "";
  18. return strPath;
  19. }
  20. CMyExcel::~CMyExcel()
  21. {
  22. COleVariant covFalse((short)FALSE);
  23. COleVariant covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
  24. MyRange.ReleaseDispatch();
  25. MySheet.ReleaseDispatch();
  26. MySheets.ReleaseDispatch();
  27. MyBook.Close(covFalse,_variant_t(strFilePath),covOptional);
  28. MyBook.ReleaseDispatch();
  29. MyBooks.Close();
  30. MyBooks.ReleaseDispatch();
  31. MyApp.Quit();
  32. MyApp.ReleaseDispatch();
  33. CoUninitialize();
  34. }
  35. BOOL CMyExcel::Open()
  36. {
  37. LPDISPATCH lpDisp=NULL;
  38. COleVariant covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
  39. CoInitialize(NULL);
  40. if (!MyApp.CreateDispatch("Excel.Application",NULL))
  41. {
  42. //AfxMessageBox(_T("EXCEL初始化时出错!"),MB_OK|MB_ICONERROR);
  43. return FALSE;
  44. }
  45. lpDisp=MyApp.GetWorkbooks();
  46. MyBooks.AttachDispatch(lpDisp,TRUE);
  47. lpDisp = MyBooks.Add(covOptional);
  48. MyBook.AttachDispatch(lpDisp,TRUE);
  49. lpDisp=MyBook.GetWorksheets();
  50. MySheets.AttachDispatch(lpDisp,TRUE);
  51. return TRUE;
  52. }
  53. BOOL CMyExcel::Open(CString strFile)
  54. {
  55. LPDISPATCH lpDisp=NULL;
  56. //CoInitialize(NULL);
  57. //if (!MyApp.CreateDispatch("Excel.Application",NULL))
  58. //{
  59. // //AfxMessageBox(_T("EXCEL初始化时出错!"),MB_OK|MB_ICONERROR);
  60. // return FALSE;
  61. //}
  62. lpDisp=MyApp.GetWorkbooks();
  63. MyBooks.AttachDispatch(lpDisp,TRUE);
  64. lpDisp = MyBooks.Open(strFile, vtMissing, vtMissing, vtMissing,
  65. vtMissing, vtMissing, vtMissing, vtMissing, vtMissing, vtMissing, vtMissing, vtMissing,vtMissing);
  66. MyBook.AttachDispatch(lpDisp,TRUE);
  67. lpDisp=MyBook.GetWorksheets();
  68. MySheets.AttachDispatch(lpDisp,TRUE);
  69. strFilePath=strFile;
  70. return TRUE;
  71. }
  72. //判断Excel软件是否已经安装
  73. bool CMyExcel::IsExistExcel()
  74. {
  75. bool bRet=true;
  76. LPDISPATCH lpDisp=NULL;
  77. CoInitialize(NULL);
  78. if (!MyApp.CreateDispatch("Excel.Application",NULL))
  79. {
  80. //AfxMessageBox(_T("EXCEL初始化时出错!"),MB_OK|MB_ICONERROR);
  81. return false;
  82. }
  83. return bRet;
  84. }
  85. BOOL CMyExcel::OpenSheet(CString strSheet)
  86. {
  87. LPDISPATCH lpDisp=NULL;
  88. long len;
  89. len=MySheets.GetCount();
  90. for(long i=1;i<=len;i++)
  91. {
  92. lpDisp=MySheets.GetItem((_variant_t)(long)i);
  93. MySheet.AttachDispatch(lpDisp,TRUE);
  94. CString str=MySheet.GetName();
  95. if(MySheet.GetName()==strSheet)
  96. {
  97. lpDisp=MySheet.GetCells();
  98. MyRange.AttachDispatch(lpDisp,TRUE);
  99. return TRUE;
  100. }
  101. }
  102. return FALSE;
  103. }
  104. BOOL CMyExcel::SetItemText(long Row,long Col,CString strText)
  105. {
  106. long lRow=0,lCol=0;
  107. lRow=GetRowS();
  108. lCol=GetColS();
  109. if(Row>lRow ||Col>lCol)
  110. {
  111. CString strText;
  112. strText.Format("由于(%d,%d)已经超过了(%d,%d)的范围,所以在(%d,%d)设置失败!"
  113. ,Row,Col,lRow,lCol,Row,Col);
  114. AfxMessageBox(_T(strText),MB_OK|MB_ICONERROR);
  115. return FALSE;
  116. }
  117. MyRange.SetItem(_variant_t(Row), _variant_t(Col), _variant_t(strText));
  118. return TRUE;
  119. }
  120. CString CMyExcel::GetItemText(long Row,long Col)
  121. {
  122. CString strValue=_T("");
  123. long lRow=0,lCol=0;
  124. lRow=GetRowS();
  125. lCol=GetColS();
  126. if(Row>lRow ||Col>lCol)
  127. {
  128. CString strText;
  129. strText.Format("由于(%d,%d)已经超过了(%d,%d)的范围,所以返回空值"
  130. ,Row,Col,lRow,lCol,Row,Col);
  131. AfxMessageBox(_T(strText),MB_OK|MB_ICONERROR);
  132. return strValue;
  133. }
  134. VARIANT lpDisp=MyRange.GetItem(_variant_t(Row), _variant_t(Col));
  135. Range rgRgeValue;
  136. rgRgeValue.AttachDispatch(lpDisp.pdispVal, TRUE);
  137. _variant_t vtVal = rgRgeValue.GetValue();
  138. if (vtVal.vt == VT_EMPTY)
  139. {
  140. rgRgeValue.ReleaseDispatch();
  141. strValue = _T("");
  142. rgRgeValue.ReleaseDispatch();
  143. return strValue;
  144. }
  145. vtVal.ChangeType(VT_BSTR);
  146. strValue= vtVal.bstrVal;
  147. rgRgeValue.ReleaseDispatch();
  148. return strValue;
  149. }
  150. void CMyExcel::SaveAs(CString strPath)
  151. {
  152. if(IsFileExist(strPath,FALSE)==TRUE)
  153. DeleteFile(strPath);
  154. MyBook.SaveAs(_variant_t(strPath),vtMissing,vtMissing,vtMissing,vtMissing,vtMissing
  155. ,0,vtMissing,vtMissing,vtMissing,vtMissing);
  156. strFilePath=strPath;
  157. // AfxMessageBox(_T("Excel保存成功"),MB_OK|MB_ICONINFORMATION);
  158. }
  159. void CMyExcel::Save()
  160. {
  161. MyBook.Save();
  162. // AfxMessageBox(_T("Excel保存成功"),MB_OK|MB_ICONINFORMATION);
  163. }
  164. void CMyExcel::AddSheet(CString strSheet)
  165. {
  166. LPDISPATCH lpDisp=NULL;
  167. lpDisp=MySheets.Add(vtMissing,vtMissing,vtMissing,vtMissing);
  168. MySheet.AttachDispatch(lpDisp,TRUE);
  169. MySheet.SetName(strSheet);
  170. lpDisp=MySheet.GetCells();
  171. MyRange.AttachDispatch(lpDisp,TRUE);
  172. }
  173. void CMyExcel::GetRange(CString strBegin,CString strEnd)
  174. {
  175. MyRange=MySheet.GetRange(_variant_t(strBegin),_variant_t(strEnd));
  176. }
  177. void CMyExcel::AutoColFit()
  178. {
  179. Range rg=MyRange.GetEntireColumn();
  180. rg.AutoFit();
  181. rg.ReleaseDispatch();
  182. }
  183. void CMyExcel::AutoRowFit()
  184. {
  185. Range rg=MyRange.GetEntireRow();
  186. rg.AutoFit();
  187. rg.ReleaseDispatch();
  188. }
  189. void CMyExcel::SetWrapText(BOOL blnTrue)
  190. {
  191. MyRange.SetWrapText((_variant_t)(short)blnTrue);
  192. }
  193. void CMyExcel::SetVisible(BOOL blnVisible)
  194. {
  195. if(blnVisible==TRUE)
  196. if(strFilePath!="")
  197. {
  198. if(IsFileExist(strFilePath,FALSE))
  199. {
  200. Exit();
  201. ShellExecute(NULL,"open",strFilePath,NULL,NULL,SW_SHOW);
  202. }
  203. else
  204. {
  205. CString strName;
  206. strName="路径"+strFilePath+"错误,不能打开显示!";
  207. AfxMessageBox(strFilePath,MB_OK|MB_ICONINFORMATION);
  208. }
  209. }
  210. else
  211. {
  212. AfxMessageBox("请先存文件后,方可打开!",MB_OK|MB_ICONINFORMATION);
  213. }
  214. }
  215. void CMyExcel::SetFont(MyFont font)
  216. {
  217. FontExcel f=MyRange.GetFont();
  218. f.SetName(_variant_t(font.Name));
  219. f.SetShadow((_variant_t)(short)font.Shadow);
  220. f.SetSize((_variant_t)(short)font.size);
  221. f.SetUnderline((_variant_t)(short)font.Underline);
  222. f.SetBold((_variant_t)(short)font.Bold);
  223. f.SetColor((_variant_t)(long)font.ForeColor);
  224. f.SetItalic((_variant_t)(short)font.Italic);
  225. f.SetStrikethrough((_variant_t)(short)font.Strikethrough);
  226. f.SetSubscript((_variant_t)(short)font.Subscript);
  227. f.SetSuperscript((_variant_t)(short)font.Subscript);
  228. f.ReleaseDispatch();
  229. }
  230. void CMyExcel::SetAlignment(MyAlignment XMyAlignment)
  231. {
  232. MyRange.SetHorizontalAlignment((_variant_t)(short)XMyAlignment.HorizontalAlignment);
  233. MyRange.SetVerticalAlignment((_variant_t)(short)XMyAlignment.VerticalAlignment);
  234. }
  235. void CMyExcel::AutoRange()
  236. {
  237. LPDISPATCH lpDisp=NULL;
  238. lpDisp=MySheet.GetCells();
  239. MyRange.AttachDispatch(lpDisp,TRUE);
  240. }
  241. void CMyExcel::SetMergeCells(BOOL blnTrue)
  242. {
  243. if(blnTrue==TRUE)
  244. {
  245. int i,j;
  246. long Row=GetRowS();
  247. long Col=GetColS();
  248. for(j=2;j<=Col;j++) SetItemText(1,j,"");
  249. for(i=2;i<=Row;i++)
  250. for(j=1;j<=Col;j++)
  251. SetItemText(i,j,"");
  252. }
  253. MyRange.SetMergeCells((_variant_t)(short)blnTrue);
  254. }
  255. void CMyExcel::SetBackStyle(MyBackStyle BackStyle)
  256. {
  257. LPDISPATCH lpDisp=NULL;
  258. Interior Itor;
  259. lpDisp=MyRange.GetInterior();
  260. Itor.AttachDispatch(lpDisp,TRUE);
  261. if(BackStyle.transparent==TRUE)
  262. Itor.SetColorIndex((_variant_t)(short)xlNone);
  263. else
  264. {
  265. Itor.SetColor((_variant_t)(long)BackStyle.Color);
  266. Itor.SetPattern((_variant_t)(short)BackStyle.Pattern);
  267. Itor.SetPatternColor((_variant_t)(long)BackStyle.PatternColor);
  268. }
  269. Itor.ReleaseDispatch();
  270. }
  271. void CMyExcel::SetBorderLine(short Xposition,MyBorder XBorder)
  272. {
  273. long Row,Col;
  274. Row=GetRowS();
  275. Col=GetColS();
  276. if(Row==1)
  277. if(Xposition==xlInsideHorizontal) return;
  278. if(Col==1)
  279. if(Xposition==xlInsideVertical) return;
  280. LPDISPATCH lpDisp=NULL;
  281. lpDisp=MyRange.GetBorders();
  282. Borders bds;
  283. bds.AttachDispatch(lpDisp);
  284. Border bd;
  285. lpDisp=bds.GetItem((long)Xposition);
  286. bd.AttachDispatch(lpDisp);
  287. bd.SetLineStyle((_variant_t)(short)XBorder.LineStyle);
  288. bd.SetColor((_variant_t)(long)XBorder.Color);
  289. bd.SetWeight((_variant_t)(short)XBorder.Weight);
  290. bd.ReleaseDispatch();
  291. bds.ReleaseDispatch();
  292. }
  293. long CMyExcel::GetRowS()
  294. {
  295. long len=0;
  296. Range rg=MyRange.GetEntireRow();
  297. len=rg.GetCount();
  298. rg.ReleaseDispatch();
  299. return len;
  300. }
  301. long CMyExcel::GetColS()
  302. {
  303. long len=0;
  304. Range rg=MyRange.GetEntireColumn();
  305. len=rg.GetCount();
  306. rg.ReleaseDispatch();
  307. return len;
  308. }
  309. void CMyExcel::SetNumberFormat(MyNumberFormat XNumberFormat)
  310. {
  311. CString strText=XNumberFormat.strValue;
  312. MyRange.SetNumberFormat(_variant_t(strText));
  313. }
  314. void CMyExcel::SetColumnWidth(int intWidth)
  315. {
  316. double f=intWidth/8.08;
  317. MyRange.SetColumnWidth((_variant_t)(double)f);
  318. }
  319. void CMyExcel::SetRowHeight(int intHeight)
  320. {
  321. double f=intHeight/8.08;
  322. MyRange.SetRowHeight((_variant_t)(double)f);
  323. }
  324. void CMyExcel::InsertPicture(CString strFilePath)
  325. {
  326. LPDISPATCH lpDisp=NULL;
  327. if(IsFileExist(strFilePath,FALSE))
  328. {
  329. // lpDisp=MySheet.get
  330. }
  331. }
  332. void CMyExcel::SetBackPicture(CString strFilePath)
  333. {
  334. if(IsFileExist(strFilePath,FALSE)==TRUE)
  335. MySheet.SetBackgroundPicture(strFilePath);
  336. }
  337. void CMyExcel::PrintOut(short CopySum)
  338. {
  339. if(CopySum<=0) CopySum=1;
  340. COleVariant covTrue((short)TRUE);
  341. COleVariant covFalse((short)FALSE);
  342. COleVariant covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
  343. MySheet.PrintOut(vtMissing,vtMissing,(_variant_t)(short)CopySum,vtMissing
  344. ,vtMissing,vtMissing,covTrue,vtMissing);
  345. }
  346. void CMyExcel::PrePrintOut(BOOL blnEnable)
  347. {
  348. COleVariant covOptional((short)blnEnable);
  349. MySheet.PrintPreview(covOptional);
  350. }
  351. BOOL CMyExcel::IsFileExist(CString strFn, BOOL bDir)
  352. {
  353. HANDLE h;
  354. LPWIN32_FIND_DATA pFD=new WIN32_FIND_DATA;
  355. BOOL bFound=FALSE;
  356. if(pFD)
  357. {
  358. h=FindFirstFile(strFn,pFD);
  359. bFound=(h!=INVALID_HANDLE_VALUE);
  360. if(bFound)
  361. {
  362. if(bDir)
  363. bFound= (pFD->dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)!=NULL;
  364. FindClose(h);
  365. }
  366. delete pFD;
  367. }
  368. return bFound;
  369. }
  370. void CMyExcel::Exit()
  371. {
  372. COleVariant covFalse((short)FALSE);
  373. COleVariant covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
  374. MyRange.ReleaseDispatch();
  375. MySheet.ReleaseDispatch();
  376. MySheets.ReleaseDispatch();
  377. MyBook.Close(covFalse,_variant_t(strFilePath),covOptional);
  378. MyBook.ReleaseDispatch();
  379. MyBooks.Close();
  380. MyBooks.ReleaseDispatch();
  381. MyApp.Quit();
  382. MyApp.ReleaseDispatch();
  383. CoUninitialize();
  384. }
  385. bool CMyExcel::IsRowEmpty( int iRow )
  386. {
  387. bool bRet=true;
  388. CString strText;
  389. for(int j=1;j<30;j++)
  390. {
  391. strText=GetItemText(iRow,j);
  392. if( strText!="" )
  393. {
  394. bRet = false;
  395. break;
  396. }
  397. }
  398. return bRet;
  399. }
  400. MyFont::MyFont()
  401. {
  402. //名字
  403. Name="Microsoft Sans Serif";
  404. //大小
  405. size=12;
  406. //前景
  407. ForeColor=RGB(0,0,0);
  408. //粗体
  409. Bold=FALSE;
  410. //斜体
  411. Italic=FALSE;
  412. //中间线
  413. Strikethrough=FALSE;
  414. //阴影
  415. Shadow=FALSE;
  416. //下标
  417. Subscript=FALSE;
  418. //上标
  419. Superscricp=FALSE;
  420. //下划线
  421. Underline=xlUnderlineStyleNone;
  422. }
  423. MyBorder::MyBorder()
  424. {
  425. //线条形状
  426. LineStyle=xlContinuous;
  427. //粗线
  428. Weight=xlThin;
  429. //颜色
  430. Color=RGB(0,0,0);
  431. }
  432. MyBackStyle::MyBackStyle()
  433. {
  434. //背景颜色
  435. Color=RGB(255,255,255);
  436. //背景图案
  437. Pattern=xlSolid;
  438. //背景图案颜色
  439. PatternColor=RGB(255,0,0);
  440. //默认为不透明
  441. transparent=FALSE;
  442. }
  443. MyAlignment::MyAlignment()
  444. {
  445. //普通
  446. HorizontalAlignment=xlGeneral;
  447. //居中对齐
  448. VerticalAlignment=xlCenter;
  449. }
  450. MyNumberFormat::MyNumberFormat()
  451. {
  452. strValue="G/通用格式";
  453. }
  454. CString MyNumberFormat::GetText()
  455. {
  456. strValue="@";
  457. return strValue;
  458. }
  459. CString MyNumberFormat::GetGeneral()
  460. {
  461. strValue="G/通用格式";
  462. return strValue;
  463. }
  464. CString MyNumberFormat::GetNumber(BOOL blnBox,int RightSum)
  465. {
  466. CString str="0";
  467. int i;
  468. if(RightSum<0) RightSum=0;
  469. if(blnBox==TRUE)
  470. {
  471. if(RightSum==0)
  472. {
  473. str="#,##0_ ";
  474. strValue=str;
  475. return strValue;
  476. }
  477. else
  478. {
  479. str="#,##0.";
  480. for(i=0;i<RightSum;i++) str=str+"0";
  481. str=str+"_ ";
  482. strValue=str;
  483. return strValue;
  484. }
  485. }
  486. else
  487. {
  488. if(RightSum==0)
  489. {
  490. str="0_ ";
  491. strValue=str;
  492. return strValue;
  493. }
  494. else
  495. {
  496. str="0.";
  497. for(i=0;i<RightSum;i++) str=str+"0";
  498. str=str+"_ ";
  499. strValue=str;
  500. return strValue;
  501. }
  502. }
  503. }
  504. CString MyNumberFormat::GetDate(BOOL blnChinese)
  505. {
  506. if(blnChinese==TRUE)
  507. strValue="yyyy\"年\"m\"月\"d\"日\";@";
  508. else
  509. strValue="yyyy-m-d;@";
  510. return strValue;
  511. }
  512. CString MyNumberFormat::GetDateTime(BOOL blnChinese)
  513. {
  514. if(blnChinese==TRUE)
  515. strValue="yyyy\"年\"m\"月\"d\"日\" h\"时\"mm\"分\"ss\"秒\";@";
  516. else
  517. strValue="yyyy-m-d h:mm:ss;@";
  518. return strValue;
  519. }
  520. CString MyNumberFormat::GetDBNumber(BOOL blnChinese)
  521. {
  522. if(blnChinese==TRUE)
  523. strValue="[DBNum1][$-804]G/通用格式";
  524. else
  525. strValue="[DBNum2][$-804]G/通用格式";
  526. return strValue;
  527. }
  528. CString MyNumberFormat::GetFractionNumBer(int DownSum,int DownNum)
  529. {
  530. CString str;
  531. int i;
  532. if(DownNum>0 && DownSum>0)
  533. {
  534. AfxMessageBox("分母位数和固定数只能设置一个,默认返回分母位数的设置!"
  535. ,MB_ICONINFORMATION|MB_OK);
  536. }
  537. if(DownSum<=0)
  538. {
  539. if(DownNum<=0)
  540. {
  541. str="# ?/1";
  542. strValue=str;
  543. return strValue;
  544. }
  545. else
  546. {
  547. str.Format("# ?/%d",DownNum);
  548. strValue=str;
  549. return strValue;
  550. }
  551. }
  552. else
  553. {
  554. str="# ?/";
  555. for(i=0;i<DownSum;i++) str=str+"?";
  556. strValue=str;
  557. return strValue;
  558. }
  559. }
  560. CString MyNumberFormat::GetMoney(BOOL blnChinese,int RightSum)
  561. {
  562. CString str;
  563. int i;
  564. if(RightSum<=0) RightSum=0;
  565. if(blnChinese==TRUE)
  566. {
  567. if(RightSum==0)
  568. {
  569. str="#,##0";
  570. strValue="¥"+str+";"+"¥-"+str;
  571. return strValue;
  572. }
  573. else
  574. {
  575. str="#,##0.";
  576. for(i=0;i<RightSum;i++) str=str+"0";
  577. strValue="¥"+str+";"+"¥-"+str;
  578. return strValue;
  579. }
  580. }
  581. else
  582. {
  583. if(RightSum==0)
  584. {
  585. str="#,##0";
  586. strValue="$"+str+";"+"$-"+str;
  587. return strValue;
  588. }
  589. else
  590. {
  591. str="#,##0.";
  592. for(i=0;i<RightSum;i++) str=str+"0";
  593. strValue="$"+str+";"+"$-"+str;
  594. return strValue;
  595. }
  596. }
  597. }
  598. CString MyNumberFormat::GetPercentNumBer(int RightSum)
  599. {
  600. CString str;
  601. int i;
  602. if(RightSum<=0) RightSum=0;
  603. if(RightSum==0)
  604. {
  605. str="0%";
  606. strValue=str;
  607. return strValue;
  608. }
  609. else
  610. {
  611. str="0.";
  612. for(i=0;i<RightSum;i++) str=str+"0";
  613. strValue=str+"%";
  614. return strValue;
  615. }
  616. }
  617. CString MyNumberFormat::GetTechNumBer(int RightSum)
  618. {
  619. CString str;
  620. int i;
  621. if(RightSum<=0) RightSum=0;
  622. str="0.";
  623. for(i=0;i<RightSum;i++) str=str+"0";
  624. strValue=str+"E+00";
  625. return strValue;
  626. }
  627. CString MyNumberFormat::GetTime(BOOL blnChinese)
  628. {
  629. if(blnChinese==TRUE)
  630. {
  631. strValue="h\"时\"mm\"分\"ss\"秒\";@";
  632. return strValue;
  633. }
  634. else
  635. {
  636. strValue="h:mm:ss;@";
  637. return strValue;
  638. }
  639. }
  640. CString MyNumberFormat::GetPost(int Sum)
  641. {
  642. int i;
  643. CString str="";
  644. if(Sum<=0) Sum=1;
  645. for(i=0;i<Sum;i++)
  646. str=str+"0";
  647. strValue=str;
  648. return strValue;
  649. }