Solved! the problem was the Adobe printer, solved changing the default printer as Microsfot Print to PDF
From excel to PDF with option
조회 수: 10 (최근 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!