我正在開發SharePoint Web部件。我有自定義的SharePoint服務器功能區。 Sharepoint服務器功能區現在包含一個按鈕。在clincking這個按鈕上,我將sharepoint庫中的xlsx文件下載到我的本地驅動器中。現在我想將這個下載的xlsx文件轉換成pdf文件。然後我想將這個pdf文件上傳到sharepoint中的一個文檔庫。對於自定義服務器功能區和操作按鈕回傳我使用下面的鏈接中提供的代碼示例下載如何將excel文件(xslx文件)轉換爲sharepoint web部件中的pdf?
Customizing and Extending the SharePoint 2010 Server Ribbon
的代碼示例是爲我工作的罰款。我已將xlsx文件下載到本地文件夾。現在,我想轉換此下載XLSX文件,這是對本地文件夾爲PDF文件,所以我使用下面的鏈接
在上面的鏈接中給出的代碼示例也是在控制檯應用程序的工作文件對我來說。我能夠在控制檯應用程序中將xlsx文件轉換爲pdf文件。但是,當我將代碼複製並粘貼到SharePoint項目中時,它不起作用。我無法理解爲什麼相同的代碼不適用於SharePoint項目?代碼如下所示
SautinSoft.UseOffice u = new SautinSoft.UseOffice();
//Path to any local file
string inputFilePath = "D:\\a.xlsx";
//string inputFilePath = "http://shailesh-pc/TemplateInvoice/Template.xlsx";
//Path to output resulted file
string outputFilePath = "D:\\afadfasfd.pdf";
//string outputFilePath = "http://shailesh-pc/Invoice/aa.xlsx";
//Prepare UseOffice .Net, loads MS Excel in memory
int ret = u.InitExcel();
//Return values:
//0 - Loading successfully
//1 - Can't load MS Excel library in memory
if (ret == 1)
return;
//Converting
ret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.XLSX_to_PDF);
//Release MS Excel from memory
u.CloseExcel();
//0 - Converting successfully
//1 - Can't open input file. Check that you are using full local path to input file, URL and relative path are not supported
//2 - Can't create output file. Please check that you have permissions to write by this path or probably this path already used by another application
//3 - Converting failed, please contact with our Support Team
//4 - MS Office isn't installed. The component requires that any of these versions of MS Office should be installed: 2000, XP, 2003, 2007 or 2010
if (ret == 0)
{
//Show produced file
System.Diagnostics.Process.Start(outputFilePath);
}
在SharePoint項目我得到的數值爲0 int ret = u.InitExcel();
但我在SharePoint項目線ret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.XLSX_to_PDF);
獲得價值1。爲什麼發生這種情況。是否有任何與SharePoint項目probelm,以便他們無法將xlsx文件轉換爲pdf?你可以告訴我,我需要做什麼來轉換PDF文件在Sharepoint的xlsx文件?你能提供我任何代碼或鏈接,我可以將xlsx文件轉換爲pdf文件嗎?