C# word或者excel保存或导出为PDF

需要实现一个功能,不利用第三方控件导出PDF,后来发现excel或word自带到处pdf


以下仅仅写出word到处PDF,excel代码类似

                Word.Application app = new Word.Application();
                Word.Document doc = app.Documents.Add();

                Word.Range range = doc.Paragraphs[1].Range;

                range.Text = txtText.Text;
                doc.ExportAsFixedFormat(sfd.FileName, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF);
                MessageBox.Show("Save pdf file success,file disk:" + sfd.FileName);


你可能感兴趣的:(C#)