Solved! the problem was the Adobe printer, solved changing the default printer as Microsfot Print to PDF
From excel to PDF with option
30 次查看(过去 30 天)
显示 更早的评论
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!