Removing image which was earlier there in existing excel file

Hi Team,

I am using version “37.3.30.1189” and facing some problem after saving the excel file.

Steps to reproduce:

  1. Created manually one excel file along with some image in first two 5 rows.
  2. From VB .Net code, loaded the excel file and wrote the data and saved.

After saving, observed the image was removed.

Code:
'load data from excel into DataTable
Dim filePath As String = “…\TemplateExcel.xls”
SpreadsheetInfo.SetLicense(“xxxx-xxxx-xxxx-xxxx”)
Dim ef As ExcelFile = ExcelFile.Load(filePath)
Dim ws As ExcelWorksheet = ef.Worksheets.FirstOrDefault()
Dim dto As CreateDataTableOptions = New CreateDataTableOptions()
Dim dt As DataTable = ws.CreateDataTable(dto)

Dim dict As Dictionary(Of String, String) = DictionaryForAllDisplayColumns(displayItems)

'Write data to excel
Dim increment As Integer = 0
For Each key As KeyValuePair(Of String, String) In dict
ws.Cells(5, increment).Value = key.Value
For j As Integer = 5 To workData.Rows.Count - 1
ws.Cells(j + 1, increment).Value = workData.Rows(j)(key.Key).ToString()
Next
increment += 1
Next

’ Save thee Excel file which is opened in ExcelFile object to a file
ef.Save(filePath)

Result before and after save:

Please provide the solution, how to persist the image.

Thanks,
Girish

Hi Girish,

I’m afraid that GemBox.Spreadsheet 3.7 doesn’t have support for pictures in XLS format:
https://archive.gemboxsoftware.com/spreadsheet/help37/help/html/Supported_File_Formats.htm

Can you use an XLSX format instead?

If not, you’ll need to use a newer version of GemBox.Spreadsheet:
https://www.nuget.org/packages/GemBox.Spreadsheet/

I hope this helps.

Regards,
Mario