Solved! the problem was the Adobe printer, solved changing the default printer as Microsfot Print to PDF
From excel to PDF with option
36 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i have an excel file with some sheets.
I need to take a defined sheet and print to a PDF (landscape orientation) with A4 size.
I've tried a lot of solutions but have some problem, with actxserver:
excel=actxserver('Excel.Application');
workbook=excel.Workbooks.Open('Excel_file_name'); % pick the correct xlsx file
worksheet=workbook.Worksheets.Item(1); % Choose desired sheet
worksheet.PageSetup.Orientation = 2; %to set the page to landscape
% customize the margin, usefull but not mandatory
worksheet.PageSetup.LeftMargin = 15;
worksheet.PageSetup.RightMargin =10;
worksheet.PageSetup.PaperSize=9; % 9 should be tha A4, tried but useless
worksheet.PageSetup.Zoom = false; %zoom must set to false, otherwise FitToPagesWide will be ingnored
worksheet.PageSetup.FitToPagesWide = 1;
worksheet.PageSetup.PrintArea='A1:AK38'; % useful but not mandatory
% print trials
worksheet.ExportAsFixedFormat('xlTypePDF','PDF_file_name',[],[],'false'); % with this it came out not in A4 but bigger
worksheet.PrintOut % with this it ask me a confirmation of the name and directory and considering that is in a for cycle to 100 files it is not a good idea...
worksheet.PrintOut(1,1,1,false,excel.ActivePrinter,true,false,name) % it gave me an error because it try to save an prn format file
Risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!