【发布时间】:2012-01-31 21:34:13
【问题描述】:
我正在开发 sharepoint Web 部件。我已经自定义了共享点服务器功能区。 Sharepoint 服务器功能区现在包含一个按钮。在单击此按钮时,我正在将 sharepoint 库中的 xlsx 文件下载到我的本地驱动器之一。现在我想把这个下载的 xlsx 文件转换成 pdf 文件。然后我想将此pdf文件上传到sharepoint中的一个文档库。为了自定义服务器功能区和处理按钮回发,我使用以下链接,其中提供了代码示例供下载
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 项目中,我在 int ret = u.InitExcel(); 处得到值 0,但在 sharepoint 项目中,我在行 ret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.XLSX_to_PDF); 处得到值 1。为什么会这样。 sharepoint 项目是否有任何问题,以至于他们无法将 xlsx 文件转换为 pdf ?你能告诉我我需要做什么才能在sharepoint中将xlsx文件转换为pdf格式吗?您能否提供我可以将 xlsx 文件转换为 pdf 文件的任何代码或链接?
【问题讨论】:
标签: c# pdf sharepoint-2010 xlsx