Convert contents of a formatted excel cell to HTML format

Hi All,
Background: I am writing a script that uploads some test cases written in excel into Quality Center. For those who are familiar with the QC Excel Addin, this script would do a pretty similar job except for reducing
the steps involved. I'm using Office 2007 running on Win 7 Pro.
Need: I have a situation where the contents of a formatted excel cell need to be converted to HTML tags representing the same formattin in the excel cell. For example a cell containg the text: "Verify
if help topics in Macro section are
hyperlinked" should be converted to
<html><b>Verify</b> if help topics in <u>Macro section</u> are <i>hyperlinked</i></html> 
Question: Is there an inbuilt function in Excel/VBAn accomplish this? Or is a macro required? Any other ideas to accomplish this?
Note: Whatever used for converting (an inbuilt function or a macro) should support new line characters and colors.
Any help or redirection to solutions is appreciated.
Thanks, John.
--Thanks, John Jacob Tharakan

Here is the function I wrote. This handles the conversion character by character.
Function fnConvert2HTML(myCell As Range) As String
Dim bldTagOn, itlTagOn, ulnTagOn, colTagOn As Boolean
Dim i, chrCount As Integer
Dim chrCol, chrLastCol, htmlTxt As String
bldTagOn = False
itlTagOn = False
ulnTagOn = False
colTagOn = False
chrCol = "NONE"
htmlTxt = "<html>"
chrCount = myCell.Characters.Count
For i = 1 To chrCount
With myCell.Characters(i, 1)
If (.Font.Color) Then
chrCol = fnGetCol(.Font.Color)
If Not colTagOn Then
htmlTxt = htmlTxt & "<font color=#" & chrCol & ">"
colTagOn = True
Else
If chrCol <> chrLastCol Then htmlTxt = htmlTxt & "</font><font color=#" & chrCol & ">"
End If
Else
chrCol = "NONE"
If colTagOn Then
htmlTxt = htmlTxt & "</font>"
colTagOn = False
End If
End If
chrLastCol = chrCol
If .Font.Bold = True Then
If Not bldTagOn Then
htmlTxt = htmlTxt & "<b>"
bldTagOn = True
End If
Else
If bldTagOn Then
htmlTxt = htmlTxt & "</b>"
bldTagOn = False
End If
End If
If .Font.Italic = True Then
If Not itlTagOn Then
htmlTxt = htmlTxt & "<i>"
itlTagOn = True
End If
Else
If itlTagOn Then
htmlTxt = htmlTxt & "</i>"
itlTagOn = False
End If
End If
If .Font.Underline > 0 Then
If Not ulnTagOn Then
htmlTxt = htmlTxt & "<u>"
ulnTagOn = True
End If
Else
If ulnTagOn Then
htmlTxt = htmlTxt & "</u>"
ulnTagOn = False
End If
End If
If (Asc(.Text) = 10) Then
htmlTxt = htmlTxt & "<br>"
Else
htmlTxt = htmlTxt & .Text
End If
End With
Next
If colTagOn Then
htmlTxt = htmlTxt & "</font>"
colTagOn = False
End If
If bldTagOn Then
htmlTxt = htmlTxt & "</b>"
bldTagOn = False
End If
If itlTagOn Then
htmlTxt = htmlTxt & "</i>"
itlTagOn = False
End If
If ulnTagOn Then
htmlTxt = htmlTxt & "</u>"
ulnTagOn = False
End If
htmlTxt = htmlTxt & "</html>"
fnConvert2HTML = htmlTxt
End Function
Function fnGetCol(strCol As String) As String
Dim rVal, gVal, bVal As String
strCol = Right("000000" & Hex(strCol), 6)
bVal = Left(strCol, 2)
gVal = Mid(strCol, 3, 2)
rVal = Right(strCol, 2)
fnGetCol = rVal & gVal & bVal
End Function
--Thanks, John Jacob Tharakan

Similar Messages

  • Format Excel cell

    Hi,
    I am writing a program that will send out an email with an excel attachment. When I open the excel file, it does show the leading zeros if the value contents only digits. For example. if the plant is '0005' the file displays just '5'. Do you know how to format the cell to text field?
    I am using FM 'SO_DOCUMENT_SEND_API1' for the email sending.
    Thanks,
    Chuong

    Hi,
    If you are using OLE automation to create the excel, you should format the cell like this:
    SET PROPERTY OF cell 'NumberFormat' = '@'.
    Regards,
    Claudiu

  • Html code stored in text format, get back in html format

    Hello All, I am not much in to Database, but for one of our BI Development, we need this. We have a column which stores the html input from a webpage in text format. for example: '
    ' is stored in DB as '<html>' '<' and '&gt' are codes for < and > symbols. so is there any way to get the values from the DB in the HTML format like < and >. there are many other characters, not just these 2. If someone can point to, if we have any predefined function if we can convert into HTML? Thanks a lot in Advance, Regards, KN

    I can't really tell from your description, but it sounds like you are doing it wrong and should do this: Oracle® XML DB Developer's Guide Contents

  • Formatting OBPM Process Report HTML Format

    Hi All,
    We have developed few processes in Business Process Composer and generated the Process Report HTML format. We found these reports need to be formatted as per our business need and are looking a way to alter/modify the format/layout for these HTML reports. Can any one please suggest how do we configure/alter/format the HTML at source level.
    Can any one suggest how to save the generated HTML report.
    --- Murthy

    Hi,
    When I run report( over 28000 pages) with same data set in linux environment then report still run normally.
    I can run this report in win2k3 env developer, but my customer can't run it(my customer also use application server 10gr2 in win2k3), number user of my customer is about 150 user.
    It isn't still work if I redirect report to another output. And I view Application Server -> Report Server then I see one job is running for a long time.
    Report Engine:
    Initial Engines (initEngine)     2
    Maximum Engines (maxEngine)     2
    Minimum Engines (minEngine)     1
    Maximum Jobs Before Shutdown (engLife)     50
    Maximum Idle Before Shutdown (maxIdle) (minutes)     30
    Cache Size (MB)     150
    Idle Timeout (minutes)     20
    Maximum Connections     20
    Maximum Queue Size     1000
    Trace Options: none
    Trace Mode: trace_replace
    Best regards
    Thanks.

  • Text Hyperlink from PDF (converted Word doc) to specific Excel cell in same Portfolio

    Good Morning,
    I have created a Word document with an embedded Excel sheet (both Office 2007) and created a text hyperlink within the document that points to a specific cell on a specific tab. My company wants to send our document to a customer, but will only send PDFs. When converting to PDF the hyperlink does not work any longer.
    To make the behaviour in Word one must open the embedded Excel object to the specific sheet and then copy the specific cell in question. In Word choose Paste as Hyperlink. Press Alt+F9 and then change HYPERLINK to hyperLINK. Press Alt+F9. Edit the Settings of the Hyperlink and change the Text to Display.
    Is there a way to do this with Acrobat 10? The plus side would be that the Excel document would not be embedded in Word although it would still need the Document ID of the Excel file in the portfolio. Futhermore, the Word document won't be included in the portfolio.

    While Acrobat cannot pass opening parameters to non-PDF files it can do so for PDF (under specific circumstances).
    See the "Parameters for Opening PDF Files" document at:
    http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open _parameters_v9.pdf 
    Be well...

  • Formatting Excel Cells from JSP

    Hello,
    I am outputting my resultset in excel. However, in the excel the cells are in a wrapped format. I was wondering if there is a way of changing the cell properties from the jsp itself so that it doesnt wrap. Below is my code snippet I use to ouput to excel.
    <%
         String error_date = request.getParameter("error_date");
         File filepath=new File("file.xls");
         response.setContentType("application/vnd.ms-excel");
         response.setHeader("Content-Disposition","inline; filename=" + filepath);
         response.setHeader("cache-control", "max-age=0");
    %>
    Anything I can do with the setHeader method or something that would enable me achieve my goal would be greatly appreciated.
    Thanks a lot All

    No, you would have to generate the file right in the first place rather than hoping JSP would have a tool to fix it up. Fact is, JSP doesn't know or care anything about Excel. It isn't even a good idea to use JSP to output Excel data.
    Edit: And no, there aren't any HTTP headers to fix up your Excel either. HTTP doesn't know or care anything about Excel either.
    Message was edited by:
    DrClap

  • KM Doc iView to display in HTML format

    Dear KM friends
    I created a KM Document iView to display a MS Excel file.
    My requrirement is
    1. I want to diplay that iView on click on HTMLB link
    2. I want to display that MS Excel file in HTML format, just like a link in Search result.
    plz reply me
    Thanx in advance
    Lakshmikantha

    Hi,
    You could call com.sap.km.cm.document iview with the RID of the document in order to display it's Excel content from the HTMLB Link:
    Link nameLink = new Link(resourceName);
    nameLink.setReference(docUri + resource.getRID());
    where docUri is:
    IURLGeneratorService urlService =
    (IURLGeneratorService) ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.URLGENERATOR_SERVICE);
    docUri = urlService.getRelativeUri(PathKey.CONTENT_ACCESS_PATH).toString();
    Hope this helps.
    Romano
    PS: about showing the HTML content of the Excel file - If I am right - I think that the HTML content of the Excel (PDF, DOC or other resources) is created on the TREX server and is available only when showing found indexed documents.
    I've found the class, that manages this HTMLVersion, maybe you can have use of it (or just have a look):
    <i>package: com.sapportals.wcm.control.search
    class: HighlightedContentControl
    method: renderHTMLVersion</i>

  • Sending an email in HTML format

    in order to change the mail format from PDF to HTML format, first I create  the smartform with the relevant content , secont I create a new class and implement the method with the code mentioned in the blog "sending HTML Email from SAP CRM/ERP"  and I defined at the action profile in IMG (I didn't
    add nothing but the method mentionedin the blog).
    the appointment is saved and the mail is sent in HTML format . but an error message is send to the user at the crm_ic tranzaction. the error message is BS(001) " no status object is available for &".
    the message is raised from program LCRMBSVAF14 / form status_read.
    if I put break-point at the message line(86)  , the message is shown and the crm_ic tranzaction is stoped
    but if I put break-point a few lines before(line no 33)  and track each step the tranzaction function correct and the crm_ic show  an o.k. message  , I can not find a reason why the tranzaction process with break-point and don't pass with out it.
    thank you .

    rj_oregon wrote:
    If you like email me out-of-band and I can send you a full sample .txt file of "hello world" that takes 3K in plain text, 256KByte in rich-text, most of it injected.
    If it looks anything like the sample here, that's unnecessary:
                             Test_Email_Adblock_enabled.txt          
    If what you see is substantially different, though, I'd be interested in seeing it. (I can't e-mail you, though, as I don't know your e-mail address. You can find mine, though, by looking at the contact link at the bottom of any page on my site, listed in my profile here.)
    This is not a feature in adblock, I view it as a bug.
    I agree, it should not be doing that.
    My suspicion is that AdBlock works by adding this code to every page you view, thus rendering the advertising elements invisible. However, in the case of OWA, it must be inserting that code in a bad place, where it shows up in the message. Mail servers will be prone to rejecting such a message, probably because some of the strings that code uses to identify these ads might look malicious. There's nothing that I can see in that code that's actually malicious, though... just a bunch of CSS conditions that make matching elements invisible.

  • How can i make a form in access into html format?

    I am trying to convert my form in access 2013 into into html format. When i try doing so it looks 100% different on the browser than it does in access. I tried doing the export command,
    and this is what happened. What can i do to make sure that it looks the exact same and will receive the data from the database? thank you for the help

    You can avoid the Ken Burns effect, but it would be a lot of work:
    See:  http://help.apple.com/imovie/ipad/2.0/index.html#knac3eec39c6
    If you don’t want the Ken Burns effect applied to a photo, set the image position and zoom level to be the same for the start and end points.
    Adjust the movement of photos with the Ken Burns effect
    iMovie applies the Ken Burns effect to the photos you add to your project. With this effect, the camera appears to sweep across and zoom in on the photo. If there are people in the photo, iMovie uses face detection to keep faces within the viewing area.
    You can adjust the Ken Burns effect so that the motion starts and ends on the parts of the image you specify.
    In the timeline, tap the photo you want to adjust.The Ken Burns effect controls appear in the lower-right corner of the image in the viewer.
    To set the way the photo is framed at the beginning, tap the Start button .
    Pinch to zoom in or out, then drag the image in the viewer to frame it the way you want.
    To set the way the photo is framed at the end, tap the End button .
    Pinch to zoom in or out, then drag the image in the viewer to frame it the way you want.
    To close the controls, tap the Ken Burns Effect button , or tap outside of the clip.
    If you don’t want the Ken Burns effect applied to a photo, set the image position and zoom level to be the same for the start and end points.

  • HTML Formatting Auto Email messages

    We have a scenario, when we provide a status update to an SR. The activity description is sent out as an automatic email. Workflow is working fine issue is automatic email is in Text format instead of an HTML format. Reason why I need an HTML format is in the description there could be a link to a web page. This link appears as text instead of a Hyperlink.
    CRMOD Support states this as an enhancement - I was wondering if anyone has created any workarounds for this.
    Thanks

    I dont believe there is a workaround for this as the emails are sent as plain text email. This has been highlighted as a request from customers i asked them if EMOD could be used in workflow which would be great for both internal and external customers.

  • Help needed with referencing single Excel cells and formatting resulting text

    In InDesign CS5 I am putting together a 20pp catalogue of about 200 products. The plan is to have the product information, SKU code, quantity etc fixed, but have the prices (there are two i.e. pack price and individual price) being linked to an Excel spreadsheet. This is so that the prices can be updated in the Excel file and the InDesign file will pull the new prices through. In case you are wondering why I don't pull the whole set of information through, this is because there are a lot of copywriting changes done to the information once it's in InDesign - it's only going to be the prices that will be updated.
    I am planning on having two single cell tables in their own text frame, duly formatted with cell style, table style and paragraph style for the two price variables. This I am then going to have to repeat 200 times making sure I link to the next row down in Excel. This is going to be a hideous task but I see know way of modifying the cell in InDesign to point it to the next row in Excel. That's my first problem.
    My second problem is this. In the Excel sheet, the prices are formatted as UK currency and are therefore like this...
    £2.00
    £0.40
    £1.43
    £9.99
    £0.99
    £0.09
    What I will require is once I import that data (and refresh the data via a newly saved Excel file) is that the prices end up like this...
    £2.00
    40p
    £1.43
    £9.99
    99p
    9p
    So if the value is lower than £1.00 it needs a trailing 'p' added  and the leading zero and '£' sign stripped off. If the value is lower than £0.10 it also needs the zero after the decimal point stripping off.
    Then formatting wise, the '£' sign needs to be superscripted and the same for the 'p'. This I am assuming could be done via GREP?
    In summary, can anyone help with the first task of referecing the Excel cells on a cell by cell basis, given that it is the same cell column each time, but the next row down, and also point me in the right direction of the price formattting issues.
    Any help will be gratefully received.

    I would do this:
    Create on line with the formatting.
    Export as InDesign tagged text (TXT)
    Read out these tags
    In Excel exists a function to connect text from several cells and predfined text, there connect the content from cells with the paragraph styling tags. Do it in a seperate sheet. (Better would be to use a database like Access, there you can link your Excel sheet).
    Export this sheet as txt file
    Place this sheet as tagged text (there is an option in one of the sialog boxes).
    In preferences  < file handling you can specify that Tablecalculation Sheets and text is not embedded but linked, turn it on.

  • Excel cell border disappears when converting to PDF (continued)

    Continuing from http://www.adobeforums.com/webx/.59b4dd40 which was archived already.
    I too am getting the problem in which Excel cell borders are disappearing from cells with a background color. Lowering the resolution to 300 dpi does not help.
    The borders are definitely disappearing. Printing the worksheet from Excel 2003 prints the cell borders. Printing the worksheet from the resulting PDF does not. I created the PDF using the Create PDF macro that Acrobat 9 adds to Excel.
    Here's the really odd thing: it only affects two adjacent cells in the same (first) row of the worksheet. Other cells with the same background color in the same columns or the same row are not affected, nor are the cells in other rows or columns.
    Copying similar cells that don't have the problem, then re-converting doesn't help.

    I just tested inserting a blank row 1 in the spreadsheet, moving the problem cells to C2 and D2, but the borders still disappear from those cells.
    Restoring back to C1 and D1, I note that if I copy the cell formats to other worksheets, the problem cells lose their borders on all worksheets.
    I then tested what happened if I specified No Color for C1 and D1. The problem transferred to cells G1 and H1, which had then become the first adjacent cells with background color.
    Restoring the background color to C1 and D1 transferred the problem back to C1 and D1, and removed the problem from G1 and H1.
    Next, I gave cell A1 a background color of white. This removed the problem from cells C1 and D1, and gave it to A1.
    Finally, I turned accessibility tagging off and that made the problem go away. However, I need tagging as we must post accessible documents.
    So now I have a consistent way to describe the problem: cell borders disappear from the first set of contiguous cells with background colors if tagging is turned on. I'm going to file this as a bug.
    Charles "Chas" Belov
    SFMTA Webmaster
    http://www.sfmta.com/webmaster

  • How to convert table content into html format?

    Hi,
    Experts,
    How to convert internal data into HTML format is there any function module or piece of code to download content into HTML.
    Thank u,
    Shabeer Ahmed.

    Then use this code....
    REPORT  ytest_table_html1.
    *        D A T A   D E C L A R A T I O N
    *-HTML Table
    DATA:
      t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE,
                                           " Html Table
    *- Declare Internal table and Fieldcatalog
      it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE,
                                           " Flights Details
      it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
                                           " Fieldcatalog
    *-Variables
    DATA:
      v_lines TYPE i,
      v_field(40).
    *-Fieldsymbols
    FIELD-SYMBOLS: <fs> TYPE ANY.
    *        S T A R T - O F - S E L E C T I O N
    START-OF-SELECTION.
      SELECT *
        FROM sflight
        INTO TABLE it_flight
        UP TO 20 ROWS.
    *        E N D - O F - S E L E C T I O N
    END-OF-SELECTION.
    *-Fill the Column headings and Properties
    * Field catalog is used to populate the Headings and Values of
    * The table cells dynamically
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'SFLIGHT'
        CHANGING
          ct_fieldcat            = it_fcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2.
      DELETE it_fcat WHERE fieldname = 'MANDT'.
      t_html-line = '<html>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<thead>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<tr>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<td><h1>Flights Details</h1></td>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</tr>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</thead>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<table border = "1">'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<tr>'.
      APPEND t_html.
      CLEAR t_html.
    *-Populate HTML columns from Filedcatalog
      LOOP AT it_fcat.
        CONCATENATE '<th bgcolor = "green" fgcolor = "black">'
            it_fcat-scrtext_l
            '</th>' INTO t_html-line.
        APPEND t_html.
        CLEAR t_html.
      ENDLOOP.
      t_html-line = '</tr>'.
      APPEND t_html.
      CLEAR t_html.
      DESCRIBE TABLE it_fcat LINES v_lines.
    *-Populate HTML table from Internal table data
      LOOP AT it_flight.
        t_html-line = '<tr>'.
        APPEND t_html.
        CLEAR t_html.
    *-Populate entire row of HTML table Dynamically
    *-With the Help of Fieldcatalog.
        DO v_lines TIMES.
          READ TABLE it_fcat INDEX sy-index.
          CONCATENATE 'IT_FLIGHT-' it_fcat-fieldname INTO v_field.
          ASSIGN (v_field) TO <fs>.
          t_html-line = '<td>'.
          APPEND t_html.
          CLEAR t_html.
          t_html-line = <fs>.
          APPEND t_html.
          CLEAR t_html.
          t_html-line = '</td>'.
          APPEND t_html.
          CLEAR t_html.
          CLEAR v_field.
          UNASSIGN <fs>.
        ENDDO.
        t_html-line = '</tr>'.
        APPEND t_html.
        CLEAR t_html.
      ENDLOOP.
      t_html-line = '</table>'.
      APPEND t_html.
      CLEAR t_html.
    *-Download  the HTML into frontend
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'C:\Flights.htm'
        TABLES
          data_tab                = t_html
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    *-Display the HTML file
      CALL METHOD cl_gui_frontend_services=>execute
        EXPORTING
          document               = 'C:\Flights.htm'
          operation              = 'OPEN'
        EXCEPTIONS
          cntl_error             = 1
          error_no_gui           = 2
          bad_parameter          = 3
          file_not_found         = 4
          path_not_found         = 5
          file_extension_unknown = 6
          error_execute_failed   = 7
          synchronous_failed     = 8
          not_supported_by_gui   = 9
          OTHERS                 = 10.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    none of the above function modules r obsolete...

  • Excel Mac £ sign keeps reverting to $ sign on saving file even when I have formatted the cells and checked the preferences

    Excel Mac - £ sign keeps reverting to $ sign on saving even though I have formatted the cells correctly to £ and in the preferences too?

    Please can you type me a response to my question. I cannot find it http://answers.microsoft.com/en-us/mac/forum/macexcel here.
    Thank you.

  • Converting formatted excel date to useful data in labview

    I am using the report generation toolkit for Office, and reading an excel file.  All the data comes back fine, except for the date column.  In excel the column is formatted as a date (ex. 5/5/05) but when it comes through in labview it ends up being something like "37740", it's the same effect if you switch the format in excel to general, the date changes to a number.  Is there anyway to leave the formatting the way it is in Excel and still bring into labview a useful date, or would I have to format the excel file differently?
    Thanks.

    I think I have it figured out using the Excel serial number date.  I attached a vi of something I threw together quickly to convert excel date serial numbers to labview date info.  I'm not 100% if it works all the time, but the few examples I tried worked fine.
    Attachments:
    Excel date to labview date.vi ‏53 KB

Maybe you are looking for