Is there an example of printing an Excel sheet programmatically from MATLAB 7.8 (R2009a)?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 3 de Feb. de 2010
Comentada: Walter Roberson
el 23 de En. de 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.
Respuesta aceptada
MathWorks Support Team
el 3 de Feb. de 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 comentario
Walter Roberson
el 23 de En. de 2016
Bheki Ngobe, you included your code, but you did not include the error message.
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!