Excel Interop Used In Web Service

If you are using the Excel Interop in a web serviceĀ or even a web page you may get the following error.

Error:

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

Generally speaking you probably should not be trying to use the Excel application from a web services or web page for security reasons; however, for my purpose I needed to do some manipulation at the server level. If you must use the Excel interop at the server level you can use the following to get around the error. Just be careful as you may be opening a security nightmare by possibly allowing remote access to it by viruses or other rogue services.

Solution:

goto Controlpanel –>Administrative tools–>Component Services –>computers –>myComputer –>DCOM Config –>Microsoft Excel Application.
right click to get properties dialog. Goto Security tab and customize permissions accordingly.
In Launch and Application Permissions, select Customize, Edit. Add the user / group that calls the application.

Converting a PDF to Excel

Converting a PDF to Excel using InvestInTech.com’s PDF to Excel SDK.

PDF Sharp and other SDKs had the ability to read text from a PDF; however, I had found that InvestInTech’s PDF to Excel kept data in grid form.
This made it easier to use OLEDB to query the excel and strip the data as needed. I had tried InvestInTech’s XML conversion, but it did not have the same clean results.

Here is a sample of how I had accomplished the conversion.

String name = Path.GetFileNameWithoutExtension(filename);
String directory = @"C:temp";

String[] files = Directory.GetFiles(directory);

Int32 iCount = 0;
foreach (String file in files)
{
iCount++;
toolStripStatusLabel2.Text = " - Converting PDF to Excel File# " + iCount + " of " + files.Count();
Application.DoEvents();

CPDF2ExcelClass pdf2Excel = new CPDF2ExcelClass();
IPDF2Excel iPDF2Excel = pdf2Excel;

iPDF2Excel.PDF2Excel(file, file.Replace(".pdf", ".xls"));

toolStripStatusLabel2.Text = " - Converting PDF to Tiff File# " + iCount + " of " + files.Count();
Application.DoEvents();
ConvertPDFToTiff(file);

File.Delete(file);
}