ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2007 insert HTML with images (https://www.excelbanter.com/excel-programming/410841-excel-2007-insert-html-images.html)

Excel 2007 insert HTML with images

Excel 2007 insert HTML with images
 
Hi2all!

I want add to active Worksheet content of 1 HTML file, which consist of
paragraphs, tables and images. I use the following code to do this:

public void InsertHTML()
{
object connection = @"URL;C:\html\test_html.html";
Range curRange = (Range)this.Application.Selection;
Worksheet curSheet = (Worksheet)this.Application.ActiveSheet;
QueryTable tblQuery = curSheet.QueryTables.Add(connection, curRange, missing);
tblQuery.BackgroundQuery = true;
tblQuery.TablesOnlyFromHTML = false;
tblQuery.Refresh(false);
tblQuery.SaveData = true;
tblQuery.Delete();
}

And I have 2 problems:
1) no images from source 'test_html.html' file is inserted into worksheet;
2) no table column width is derived from source file

But when I press Ctrl+O from Excel and open this HTML file, all images and
table styles import correctly! How I can get the same in my VSTO add-in?


All times are GMT +1. The time now is 03:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com