This article illustrates the method of printing word,excel text file in VC. Share to everyone for your reference. The implementation methods are as follows:
1. VC Print Excel:
About VC How to open an Excel, this aspect of information a lot of, general use is OLE avtive control/assume when you open an Excel file, and get it's
Workbook handle, the corresponding interface is:
Copy Code code as follows:
COleVariant covtrue ((short) true);
COleVariant covfalse ((short) FALSE);
COleVariant covoptional ((Long) disp_e_paramnotfound, VT_ERROR);
_workbook Objbook;
.....
Objbook.printout (covoptional,
Covoptional,
COleVariant (Long (1)),//print number of copies
Covfalse,
Covoptional,
Covoptional,
Covoptional
, covoptional
);
The reader can refer to the MSDN for the specific meaning of the other parameters.
2. VC Print Word
The print interface for Word is:
Copy Code code as follows:
_document::P rintout (Covfalse,
Covoptional,
Covoptional,
Covoptional,
Covoptional,
Covoptional,
Covoptional,
COleVariant ((long) 1),//print pages
Covoptional,
Covoptional,
Covoptional,
Covoptional,
Covoptional,
Covoptional,
Covoptional,
Covoptional,
Covoptional,
Covoptional
);
Refer to MSDN for the meaning of the parameter.
3. VC Print Excel:
Call the Shell's print function:
Copy Code code as follows:
ShellExecute (NULL, "print", "C://temp//test.txt", null,null,sw_hide);
Note that the printer is already installed on the machine. The printout is sent to the default printer. In addition, Shellexcute can also be used to print Excel and Word, replacing the corresponding filename.
Copy Code code as follows:
ShellExecute (NULL, "print", "C://temp//test.xls", null,null,sw_hide);
ShellExecute (NULL, "print", "C://temp//test.doc", null,null,sw_hide);
I hope this article on the VC program for everyone to help.