使用“IncludeDocProperties”字段将Excel转换为.pdf

时间:2022-08-13 08:57:19

I use the following code in MATLAB to convert an Excel worksheet into PDF, but I am getting the info (name) of the Excel file at the top of the PDF.

我在MATLAB中使用以下代码将Excel工作表转换为PDF,但是我正在PDF顶部获取Excel文件的信息(名称)。

How can I get rid of it?
I know there is an optional field IncludeDocProperties, but I am not sure how to use it?

我怎么才能摆脱它呢?我知道有一个可选字段IncludeDocProperties,但我不知道如何使用它?

hExcel = actxserver('Excel.Application');
hWorkbook = hExcel.Workbooks.Open(sprintf('%s',excel_filepath));     
hWorksheet = hWorkbook.Sheets.Item(1);
hWorksheet.ExportAsFixedFormat('xlTypePDF',pdf_filepath); 
hWorkbook.Close; 
hExcel.Quit; 
hExcel.delete;

1 个解决方案

#1


1  

As far as I know, convert to pdf by ExportAsFixedFormat method will give you a pdf file that looks exactly like what you get when you print out the excel file.

据我所知,通过ExportAsFixedFormat方法将pdf文件转换为pdf文件,它与您打印excel文件时得到的文件一模一样。

So, the info (name) that you mentioned is not created by Matlab, but by Excel. You have to open the file in Excel, and check if the Header/Footer is turned off or not. If you have Header/Footer turned on for the file, then the pdf exported through Matlab will also have that info (maybe file name, or page number, or author name etc.).

你提到的信息(名字)不是用Matlab创建的,而是用Excel创建的。您必须在Excel中打开文件,并检查页眉/页脚是否已关闭。如果打开了文件的页眉/页脚,那么通过Matlab导出的pdf也会有这个信息(可能是文件名、页码或作者名等)。

#1


1  

As far as I know, convert to pdf by ExportAsFixedFormat method will give you a pdf file that looks exactly like what you get when you print out the excel file.

据我所知,通过ExportAsFixedFormat方法将pdf文件转换为pdf文件,它与您打印excel文件时得到的文件一模一样。

So, the info (name) that you mentioned is not created by Matlab, but by Excel. You have to open the file in Excel, and check if the Header/Footer is turned off or not. If you have Header/Footer turned on for the file, then the pdf exported through Matlab will also have that info (maybe file name, or page number, or author name etc.).

你提到的信息(名字)不是用Matlab创建的,而是用Excel创建的。您必须在Excel中打开文件,并检查页眉/页脚是否已关闭。如果打开了文件的页眉/页脚,那么通过Matlab导出的pdf也会有这个信息(可能是文件名、页码或作者名等)。