he encotrado la solucion a este problema. te pongo el link por si te sirve todavia. Se que es de hace mucho, pero... un saludo. y si no igual le sirve a otro
http://stackoverflow.com/questions/769246/xls-to-pdf-conversion-inside-net
el codigo correcto es en la parte que pone Office 2007 (pone numero 3 en el mensaje)
hay que bajarse el http://msdn.microsoft.com/en-us/library/kh3965hw.aspx
insertar la dll en el visual studio:
1. On the Project menu, click Add Reference.
2. On the COM tab, locate Microsoft Excel Object Library, and then click Select. In Visual Studio 2005, locate Microsoft Excel 11.0 Object Library on the COM tab.
3. Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the libraries that you selected, click “Yes”.
y luego copiar el codigo que pone en el post este:
Cita: using System;
using System.IO;
using msExcel = Microsoft.Office.Interop.Excel;
namespace scpm {
public class ExcelToPdfConverter {
private static object missing = System.Reflection.Missing.Value;
public static void ConvertExcelToPdf(string excelFileIn, string pdfFileOut) {
msExcel.Application excel = new msExcel.Application();
try {
excel.Visible = false;
excel.ScreenUpdating = false;
excel.DisplayAlerts = false;
FileInfo excelFile = new FileInfo(excelFileIn);
string filename = excelFile.FullName;
msExcel.Workbook wbk = excel.Workbooks.Open(filename, missing,
missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing,
missing, missing, missing);
wbk.Activate();
object outputFileName = pdfFileOut;
msExcel.XlFixedFormatType fileFormat = msExcel.XlFixedFormatType.xlTypePDF;
// Save document into PDF Format
wbk.ExportAsFixedFormat(fileFormat, outputFileName,
missing, missing, missing,
missing, missing, missing,
missing);
object saveChanges = msExcel.XlSaveAction.xlDoNotSaveChanges;
((msExcel._Workbook)wbk).Close(saveChanges, missing, missing);
wbk = null;
}
finally {
((msExcel._Application)excel).Quit();
excel = null;
}
}
}
}
Espero que le sirva a alguien. A mi, tras varios dias intentando otras cosas al final he podido con esto!!
Un saludo