Open file from sharepoint

Hi ,

Excel documents are stored in our sharepoint portal.

We are looking to open excel workbook using Aspose cells from sharepoint, update worksheet Tab from datatable and save back to original sharepoint location.

We are looking at using C#.

Regards


Hi,

Well, you must have FileIOPermission to access and create/recreate files. And please set CellsHelper.FontDir property, otherwise we could not get the font settings or you would find other issues.

You may try the following code with Aspose.Cells for .NET @ SharePoint:
e.g
Sample code:

private void ConvertFile(SPFile sourceFile, SPFolder destFolder, string destFileName, SaveFormat destFileFormat, bool overwrite) {

try
{

Stream inputStream = sourceFile.OpenBinaryStream();

Stream outputStream = new MemoryStream();

string sourceExt = Path.GetExtension(sourceFile.Name).ToLower();


try
{

     Workbook book = <span class="kwrd">new</span> Workbook(inputStream);</font></div><div class="csharpcode"><font face="Arial">         </font></div><div class="csharpcode"><font face="Arial">         //Perform your tasks.</font></div><div class="csharpcode"><font face="Arial">        //................<br>
     book.Save(outputStream, SaveFormat.Pdf);<br>
  }<br>      <span class="kwrd">catch</span> (Exception e)<br>      {<br>
     <span class="kwrd">throw</span> <span class="kwrd">new</span> ApplicationException("Convertion Failed. " + e.Message, e);<br>

  }<br>
  outputStream.Seek(0, SeekOrigin.Begin);<br>
  destFolder.Files.Add(destFolder.Url + "/" + destFileName, outputStream, overwrite);<br>

}
catch (ArgumentException)
{
throw;

}
catch
{
throw;
}


}


Hope, this help.

Moreover, if you need to convert Excel file fomats, you should use our specific Aspose.Cells for SharePoint component for the environment, see the documentation for your refernece:
http://www.aspose.com/docs/display/cellssharepoint/Home


Thank you.