Posted By

nausherwan on 05/27/14


Tagged

excel pictures worksheet Aspose asposecells


Versions (?)

Sample Code to Add Pictures in a Worksheet using Aspose.Cells for Cloud


 / Published in: C#
 

URL: http://www.aspose.com/docs/display/cellscloud/Add+Pictures+to+Excel+Worksheet

This example shows how to add a picture to a worksheet using Aspose.Cells for Cloud API in your applications. You can use our REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.

  1. //sepcify App SID
  2. AsposeApp.AppSID = "77******-1***-4***-a***-80**********";
  3. //sepcify App Key
  4. AsposeApp.AppKey = "********************************";
  5.  
  6. //build URI
  7. string strURI = "http://api.aspose.com/v1.1/cells/Sample.xlsx/worksheets/Sheet1/pictures?upperLeftRow=5&upperLeftColumn=5&lowerRightRow=20&lowerRightColumn=20&picturePath=Dock.jpg";
  8.  
  9. //sign URI
  10. string signedURI = Utils.Sign(strURI);
  11.  
  12. Stream responseStream = Utils.ProcessCommand(signedURI, "PUT");
  13.  
  14. //build URI
  15. strURI = "http://api.aspose.com/v1.1/storage/file/Sample.xlsx";
  16.  
  17. //sign URI
  18. signedURI = Utils.Sign(strURI);
  19.  
  20. responseStream = Utils.ProcessCommand(signedURI, "GET");
  21. using (Stream fileStream = System.IO.File.OpenWrite(@"Sample.xlsx"))
  22. {
  23. Utils.CopyStream(responseStream, fileStream);
  24. }
  25. responseStream.Close();
  26.  
  27. /// <summary>
  28. /// Copies the contents of input to output. Doesn't close either stream.
  29. /// </summary>
  30. public static void CopyStream(Stream input, Stream output)
  31. {
  32. try
  33. {
  34. byte[] buffer = new byte[8 * 1024];
  35. int len;
  36. while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
  37. {
  38. output.Write(buffer, 0, len);
  39. }
  40. }
  41. catch (Exception ex)
  42. {
  43. throw new Exception(ex.Message);
  44. }
  45. }

Report this snippet  

You need to login to post a comment.