Removing image which was earlier there in existing excel file

Hi Team,

I am using version “” 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.

'load data from excel into DataTable
Dim filePath As String = “…\TemplateExcel.xls”
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()
increment += 1

’ Save thee Excel file which is opened in ExcelFile object to a file

Result before and after save:

Please provide the solution, how to persist the image.


Hi Girish,

I’m afraid that GemBox.Spreadsheet 3.7 doesn’t have support for pictures in XLS format:

Can you use an XLSX format instead?

If not, you’ll need to use a newer version of GemBox.Spreadsheet:

I hope this helps.