Resmy Ravi

Resmy Ravi

  • NA
  • 128
  • 0

Excel 2003 to pdf format

Mar 7 2012 11:14 PM

hi...

I am using vs 2010 with sql ser back end.In my project i need to export an excel sheet in 2003 format to pdf file.Is it possible.Pls give me the code.
I have tried below code,but it gives an error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."..

my code is

  string infile = "E:\\spec.xls";
  string outfile = "E:\\spec1.pdf";
  Excel.Application excelApp = null;
  try
  {
  excelApp = new Excel.Application(infile);
  excelApp.Workbooks.Open(infile);
  excelApp.ActiveWorkbook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
  }
  finally
  {
  if (excelApp != null)
  excelApp.Quit();
  }


Answers (1)