Free Trial
Web API version
Licensing
Request A Quote
HAVE QUESTIONS OR NEED HELP? SUBMIT THE SUPPORT REQUEST FORM or write email to SUPPORT@BYTESCOUT.COM
Add Images to Spreadsheet | C#
Program.cs:
C#
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; using Bytescout.Spreadsheet; namespace AddImages { class Program { static void Main(string[] args) { // Create spreadsheet Spreadsheet doc = new Spreadsheet(); // Add worksheet Worksheet worksheet = doc.Worksheets.Add(); // Put an image on the worksheet with 10 pixel margin from the top-left corner of the worksheet worksheet.Pictures.Add("image1.jpg", 10, 10); // Put second image to 200 pixel offset and resize it to 250x200 px worksheet.Pictures.Add("image2.jpg", 200, 200, 250, 200); // Delete output file if exists if (File.Exists("output.xls")) { File.Delete("output.xls"); } // Save document doc.SaveAs("output.xls"); // Close spreadsheet doc.Close(); // Open generated XLS document in default application Process.Start("output.xls"); doc.Dispose(); } } }