Is there an example of printing an Excel sheet programmatically from MATLAB 7.8 (R2009a)?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 3 Feb. 2010
Kommentiert: Walter Roberson
am 23 Jan. 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.
Akzeptierte Antwort
MathWorks Support Team
am 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 Kommentar
Walter Roberson
am 23 Jan. 2016
Bheki Ngobe, you included your code, but you did not include the error message.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!