Posted By

nausherwan on 05/23/14


Tagged

image chart Aspose asposecells chart2image


Versions (?)

Sample Code to Convert Excel Chart to Image using Aspose.Cells for Cloud


 / Published in: C#
 

This example shows how to convert a chart to image 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. string FileName = "book1.xls";
  2. string SheetName = "Sheet";
  3. string Format = "JPEG";
  4.  
  5.  
  6. //build URI to replace text
  7. string strURI = "http://api.aspose.com/v1.1/cells/" + FileName + "/worksheets/" + SheetName + "?format=" + Format;
  8. string signedURI = Utils.Sign(strURI);
  9.  
  10. //get response stream
  11. Stream responseStream = ProcessCommand(signedURI, "GET");
  12.  
  13. using (Stream fileStream = System.IO.File.OpenWrite("C:\\Temp\\output.jpg"))
  14. {
  15. CopyStream(responseStream, fileStream);
  16. }
  17. responseStream.Close();
  18.  
  19.  
  20. /// <summary>
  21. /// Copies the contents of input to output. Doesn't close either stream.
  22. /// </summary>
  23. public static void CopyStream(Stream input, Stream output)
  24. {
  25. try
  26. {
  27. byte[] buffer = new byte[8 * 1024];
  28. int len;
  29. while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
  30. {
  31. output.Write(buffer, 0, len);
  32. }
  33. }
  34. catch (Exception ex)
  35. {
  36. throw new Exception(ex.Message);
  37. }
  38. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Sharma on October 9, 2014

Thanks for the sample code..Besides using Aspose to convert Excel chart to image, I also find the following method useful. And the code is more easier.Check it out - http://www.e-iceblue.com/Tutorials/Spire.XLS/Spire.XLS-Program-Guide/Convert-Excel-to-Image-Worksheet-to-Image-in-C-VB.NET.html

You need to login to post a comment.