开发者

Can't remove borders from tables in Word export

开发者 https://www.devze.com 2022-12-13 09:33 出处:网络
I\'m having an issue when I export my html page to Word, I can\'t get rid of the borders on a table element.

I'm having an issue when I export my html page to Word, I can't get rid of the borders on a table element.

<table cellspacing="0" cellpadding="0">
    <tr>
        <td class="title">Analyst</td>
        <td>
            <asp:Label ID="lblAnalyst" runat="server" CssClass="data" />
        </td>
        <td class="title">Borrower</td>
        <td>
            <asp:Label ID="lblBorrower" runat="server" />
        </td>
    </tr>
</table>

I set the content type to Word

Response.ContentType = "application/vnd.ms-word";
Response.AddHea开发者_StackOverflowder("content-disposition", String.Concat("attachment;filename=", fileName));

No matter what I do, I still get the borders around the entire table and around each cell.

Can't remove borders from tables in Word export

I've tried setting the borders attribute on the table to 0, using inline styles and including a style in a section but nothing works. I've even tried all 3 of these together.

Any ideas? This is destined for Word 2003.


Have you considered using WordML rather than plain old HTML? Word is incredibly weird about how it imports HTML.

My suggestion would be to export a table from Word in HTML, and mimic that HTML precisely. Chances are, it will involve some funky naming for stylesheet classes and a small army of Word-specific CSS directives.


Got a workaround after searchin a lot. :D

Change the table as

<table border="1" style="border: 1px white solid" cellspacing="0" cellpadding="0" >

then on each td provide inline style(or give a class) and add the following style

border: 1px white solid

Thats all. You are done :)

/* John JB */

jcb871@gmail.com

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号