|
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Adding a picture
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
Stream imageStream = assembly.GetManifestResourceStream("SampleBrowser.XlsIO.Samples.Template.Image.png");
IPictureShape shape = worksheet.Pictures.AddPicture(1, 1, imageStream);
//Saving the workbook as stream
MemoryStream stream = new MemoryStream();
workbook.SaveAs(stream);
stream.Position = 0;
//Save the document as file and view the saved document
SaveAndroid androidSave = new SaveAndroid();
await androidSave.SaveAndView("AddingImage.xlsx", "application/msexcel", stream, this);
} |
|
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
Assembly assembly = typeof(MainActivity).GetTypeInfo().Assembly;
Stream fileStream = assembly.GetManifestResourceStream("CreateExcelSample.Sample.xlsx");
IWorkbook workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic);
IWorksheet sheet = workbook.Worksheets[0];
IPictureShape picture = sheet.Pictures[0];
Image image = picture.Picture;
byte[] byteArray = image.ImageData;
MemoryStream stream = new MemoryStream(byteArray);
stream.Position = 0;
//Save the document as file and view the saved document
SaveAndroid androidSave = new SaveAndroid();
await androidSave.SaveAndView("OutputImage.png", "application/image", stream, this);
} |