We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Image with smart markers

Hi,

I’m currently trying to insert an image using smart markers (at the end I want to generate a PDF file).
Is it possible to insert an image with another overload of the method : public void SetDataSource(DataTable dataTable) ?
Instead I would like to use the overload :
SetDataSource(string variable, object data).
The type of data should be an array of bytes.
But I get an exception when I processed the WorkbookDesigner : “Index was outside the bounds of the array”.

Do you have any idea about this issue?

Thanks,

Kind Regards

Hi,

Please create a databable and populate it with your image bytes on runtime and then use SetDataSource(DataTable dataTable)

For code example, please see this article, it has a code example that creates datatabe from the image bytes.
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/smart-markers.html

Hi,

I already saw the example about images with Smart Markers, but I would like to not use Datatable object to just insert an image in the template.

Regards

Hi,

This is a New Feature Request.

We have added this in our database. We will look into them and once it is implemented or we have some update relating to it, we will let you know asap.

This issue has been logged as CELLSNET-40291.

Hi,

Please see the following code, it shows how to add image using the bytes.

I have attached the output xlsx file and the image used in this code.

Please also see the screenshot attached by me.

C#



Workbook workbook = new Workbook();

workbook.Worksheets[0].Cells[“A1”].PutValue("&=$Variable(Picture)");

WorkbookDesigner designer = new WorkbookDesigner();

designer.Workbook = workbook;

byte[] imageData = File.ReadAllBytes(@“C:\image.jpg”);

byte[][] data = new byte[1][];

data[0] = imageData;

designer.SetDataSource(“Variable”, data);

designer.Process();


workbook.Save(@“F:\Shak-Data-RW\Downloads\output.xlsx”);

Thank you, it works now.
We have to use the type byte[][] instead of byte[] to make it work.

Why it’s not work for vb.net
Here my code below:
Dim FilePath As String = “…\Sample Files”

Dim FileName As String = FilePath & “Image Markers.xlsx”

'Get the image data.

Dim imageData() As Byte = File.ReadAllBytes(FilePath & “Aspose.Cells.png”)

'Create a datatable.

Dim t As New DataTable(“Table1”)

'Add a column to save pictures.

Dim dc As DataColumn = t.Columns.Add(“Picture”)

'Set its data type.

dc.DataType = GetType(Object)

'Add a new new record to it.

Dim row As DataRow = t.NewRow()

row(0) = imageData

t.Rows.Add(row)

But it’s not work. only show:System.Byte[] in Picture coloumn

@billni,

Could you please zip and attach a standalone console application with sample files to reproduce the issue on our end, we will check it soon.

PS. please exclude Aspose.Cells.Dll to minimize the size of the zipped archive.

I find the problem is my version of Aspose.Cells.Dll is old. After I upgraded, it works. But another problem is the Picture: FitToCell not working. Attached the file please checkCsharpaspose图片.7z (217.6 KB)

@billni,

I could not extract your zipped archive, it seems corrupted or versioning issue. Could you re-zip your resource file(s) with .zip extension and re-attach the zipped archive. We will check your issue soon.

@ Amjad_SahiCsharpaspose图片.zip (324.0 KB)

@billni,

Please notice, I am able to reproduce the issue as you mentioned by using your template file. I found “Picture:FitToCell” parameter is not working properly in image smart markers. I have logged a ticket with an id “CELLSNET-49850” for your issue. We will look into it and figure it out soon.

Once we have an update on it or a fix is available, we will update you here.

@billni
This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@billni
Please try the leat fix 21.11.4
Aspose.Cells21.11.4 For .Net2_AuthenticodeSigned.Zip (5.6 MB)
Aspose.Cells21.11.4 For .Net4.0.Zip (5.6 MB)
Aspose.Cells21.11.4 For .NetStandard20.Zip (5.6 MB)

Sorry, this file is private. Only visible to topic owner and staff members. I can’t download them.

@simon.zhao can you authorize download to me? thanks

@billni,

You are not the owner of the thread, so you might not download the attachments in the thread. Please ask for the new fix either in your other thread or in newly created thread. We will then provide you the new fix in your thread.

Can you please upload the nex fix attached in my this thread

@billni,

We shared the fix in your other thread.

The issues you have found earlier (filed as CELLSNET-49850) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao