2012-01-20 4 views
2

私はSharepoint Webパーツを開発中です。私はSharepoint Serverのリボンをカスタマイズしました。 Sharepointサーバーのリボンには1つのボタンが含まれています。このボタンをクリックすると、共有ライブラリのxlsxファイルを自分のローカルドライブにダウンロードしています。今私はこのダウンロードしたxlsxファイルをpdfファイルに変換したいと思います。次に、このpdfファイルをsharepointの1つのドキュメントライブラリにアップロードします。サーバーリボンをカスタマイズして、ボタンのポストバックを処理するために私は、コードサンプルがコードサンプルは私のために正常に動作しているダウンロードどのようにExcelファイル(xslxファイル)をSharepoint Webパーツのpdfに変換しますか?

Customizing and Extending the SharePoint 2010 Server Ribbon

のために提供されている次のリンクを使用しています。 xlsxファイルをローカルフォルダにダウンロードしました。今私は、私は上記のリンクで与えられたコードサンプルは、コンソールアプリケーションでの私のためにファイルを働いている、以下のリンク

Convert xlsx file to pdf file

を使用していますように、ローカルフォルダにあるこのダウンロードのxlsxファイルをPDFファイルに変換したいです。私はxlsxファイルをコンソールアプリケーションのpdfファイルに変換することができます。しかし、コピーポイントを実行してコードをSharePointプロジェクトに貼り付けると、動作しません。なぜ同じコードがsharepointプロジェクトで動作していないのか理解できません。私はint ret = u.InitExcel();で値0を取得しています。しかし、私はSharePointプロジェクトにラインret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.XLSX_to_PDF);で値1を取得しています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); 
     }  

を次のようにコードがあります。なぜこれが起こっているのですか? xlsxファイルをpdfに変換できないように、sharepointプロジェクトの問題はありますか?あなたはsharepointのpdfのxlsxファイルを変換するために何が必要なのか教えていただけますか? xlsxファイルをpdfファイルに変換するためのコードやリンクを教えてください。

答えて

0

MicrosoftがこのようなシナリオでOfficeオートメーションを推奨していませんので、予めご了承ください。

Microsoftは現在、推奨していませんし、任意の無人、 は、非対話型のクライアントから、Microsoft Officeアプリケーションの オートメーションをサポートしていません。この環境でOfficeを実行すると、Officeが不安定な の動作やデッドロックを発生する可能性があるため、アプリケーション、コンポーネント(ASP、 ASP.NET、DCOM、およびNTサービスを含む)を使用すると、

詳細は、http://support.microsoft.com/kb/257757で確認できます。だから、代替案を検討する方が良いです。

関連する問題