0

I'm trying to send data from json to the Excel File.
Unfortunately to work in IE I use ActiveXObject.

The problem is that my json contain the whole html tags example

<a href="www.localhost.com/index">Home</a>

or

<p><b>Welcome</b><br/>How are you today</p>

Extraction is working almost perfect. Unfortunately in my Excel are available all html tags. And cells are looking exactly like I wrote.
I want to convert them somehow to look like this

Home

and

Welcome

How are you today

Is it possible to send them already formatted to the Excel or somehow to format the cell into the Excel?

Here is my JS code:

 function extractExcel() {
        var excApp = new ActiveXObject("Excel.Application");
        var excBook = excApp.Workbooks.open("www.localhost/media/excel_template.xlsx");
        excApp.visible = true;
        excBook.Add

        var i = 1;
        var j = 0;

        $.each($scope.filteredItems, function (index, item) {
            $.each(item, function (key, value) {

                excApp.Cells(i + 1, j + 1).Value = value;

                j++;
            });
            j = 0;
            i++;
        });
    }
Kosmonaft
  • 1,286
  • 2
  • 17
  • 30
  • *The problem is that my json contain the whole html tags example* - You forgot to say why this is a problem? What is it you want to end up with in the cells? – Alex K. Oct 14 '14 at 14:26
  • Thanks for comment. I already fixed my question and I hope that is looking better. – Kosmonaft Oct 14 '14 at 17:08
  • 1
    You can do something to extract the *raw* text (should be able convert my answer [here](http://stackoverflow.com/questions/9995257/mshtml-createdocumentfromstring-instead-of-createdocumentfromurl) to jscript) but you cannot have multiple formats (bold/unbold) in a cell – Alex K. Oct 14 '14 at 17:10
  • @AlexK. actually you **can** have multiple formats in a cell. Using `cell.Characters(Start:=2, Length:=1).Font.Underline = True`. You cannot have multiple (clickable) hyperlinks in a cell – xmojmr Oct 14 '14 at 18:10
  • OK. Thanks for information. I try to add Macros to Excel file. But when I started it, he change the cell values with macros function :( I'm not very similar with Excel. Any idea what I'm doing wrong? – Kosmonaft Oct 15 '14 at 06:33

0 Answers0