Is there an example of printing an Excel sheet programmatically from MATLAB 7.8 (R2009a)?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 3 Feb 2010
Commentato: Walter Roberson
il 23 Gen 2016
I have written data to an Excel file using the XLSWRITE function using the following code.
filename = 'C:\SomeExcelFile.xls';
% Write Random Data
xlswrite(filename,rand(10));
Now I would like to programmatically print this file.
Risposta accettata
MathWorks Support Team
il 3 Feb 2010
Using the following workflow, you can print your Excel file to a printer.
filename = 'C:\SomeExcelFile.xls';
% Write Random Data
xlswrite(filename,rand(10));
Excel = actxserver('excel.application');
Excel.visible = 1
Workbooks = Excel.Workbooks;
% Make Excel visible
Excel.Visible=1;
% Open Excel file
Workbook=Workbooks.Open(filename);
% The Syntax for PrintOut on the Excel Developer reference is:
% PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate,
% PrToFileName, IgnorePrintAreas)
% It is possible to pass these arguments to the function as shown below
Excel.ActiveWorkbook.PrintOut(1,1,1,'False','PrinterName');
% You can also use the default settings and just PrintOut
% Excel.ActiveWorkbook.PrintOut
Excel.Quit;
1 Commento
Walter Roberson
il 23 Gen 2016
Bheki Ngobe, you included your code, but you did not include the error message.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!