1

Paste Excel cell intor RTF field with simple HTML

Ninox does a beautiful work when pasting a cell range into an RTF field: it is stored as HTML tables for free! That's great for our purposes but... the HTML tables stored do have some rich information that I want to clean before exporting them to EasyCatalog.

 

For example, this is the default header that is "created" in Ninox when I copy/paste a cell range into an RTF field:

 

<table border=”0” cellpadding=”0” cellspacing=”0” width=”435” style=”caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); border-collapse: collapse; width: 325pt;”>

But what I really need is this:

<table>

Same with the header. It is pasted as:

<colgroup><col width=”87” span=”5” style=”width: 65pt;”></colgroup>

This is a row:

<tr height=”21” style=”height: 16pt;”>

And this is a simple cell:

<td height=”21” class=”xl63” width=”87” style=”padding-top: 1px; padding-right: 1px; padding-left: 1px; font-size: 12pt; font-family: Calibri, sans-serif; vertical-align: bottom; border: none; white-space: nowrap; height: 16pt; width: 65pt;”>MADRID</td>

I want/need a cleaner code, like this:

<table><tr><td>"MADRID"</td>(...)</tr></table>

Can I change the preferences in Excel or in Ninox to copy/paste simple HTML tables with no formatting? Or maybe can I manipulate the complex formatting and with some Regular Expressions clean the code? For example, can I use this regular expression to clean the <table> tag?:

search for: <table.+?>
replace with: <table>

I need the resulting field to be an RTF field (because the formula fields can't be exported using the Ninos API)

1 reply

null
    • Consultant and developer
    • Javier
    • 2 yrs ago
    • Reported - view

    I found the solution by myself! Yes, Ninox can use regular expressions for search/replace with patters. The code (ugly but working) for cleaning the HTML table pasted by Excel:

    let codigo := html(Tabla_sucia);
    let limpio := replacex(raw(Tabla_sucia), "<table.+?>", "<table>");
    limpio := replacex(limpio, "<colgroup>.+</colgroup>", "");
    limpio := replacex(limpio, "<tr.+?>", "<tr>");
    limpio := replacex(limpio, "<td.+?>", "<td>");
    limpio := replacex(limpio, "<tbody>", "");
    limpio := replacex(limpio, "</tbody>", "");
    Tabla_limpia := html(limpio);
    

    It changes the nasty Excel code to a clean HTML table. 

Content aside

  • Status Answered
  • 1 Likes
  • 2 yrs agoLast active
  • 1Replies
  • 160Views
  • 1 Following