Hi
Its possible to create tables in word document using only html tables with css,
I need some tabular data, but without using tables?
Conversion from html to PDF works fine, but no in word document.
Plese help!
|
WordDocument document = new WordDocument(); document.EnsureMinimal(); document.LastParagraph.AppendHTML("<table style=\"height: 224px; border-color: black;\" border=\"1\" width=\"460\"><tbody><tr><td style=\"width: 146px;\">One </td><td style=\"width: 146px;\">two</td><td style=\"width: 146px;\">three</td></tr><tr><td style=\"width: 146px;\">four</td><td style=\"width: 146px;\">five</td><td style=\"width: 146px;\">six</td></tr><tr><td style=\"width: 146px;\">seven</td><td style=\"width: 146px;\">eight</td><td style=\"width: 146px;\">nine</td></tr></tbody></table>"); document.Save("Output.docx", FormatType.Docx); document.Close(); |
Hi Manikandan
For my requirement I need to show tables inside a table, and I have a problem with the <table> default construct.
So I want to know if using Divs and CSS I can achieve what I need..
Something like the following sample, this works fine with HTML to PDF, but not for HTML to word, info not shown like table, I get content data in a new row.
(css can be any other)
<div class='Table'>
<div class='Title'>
Sample table
</div>
<div class='Heading'>
<div class='Cell'>
header 1
</div>
<div class='Cell'>
header2
</div>
<div class='Cell'>
header 3
</div>
</div>
<div class='Row'>
<div class='Cell'>
data 1
</div>
<div class='Cell'>
data 2
</div>
<div class='Cell'>
data 3
</div>
</div>
<div class='Row'>
<div class='Cell'>
data 4
</div>
<div class='Cell'>
data 5
</div>
<div class='Cell'>
data 6
</div>
</div>
</div>
Using css like this
<style>
.Table
{
display: table;
}
.Title
{
display: table-caption;
text-align: center;
font-weight: bold;
font-size: larger;
}
.Heading
{
display: table-row;
font-weight: bold;
text-align: center;
}
.Row
{
display: table-row;
}
.Cell
{
display: table-cell;
border: solid;
border-width: thin;
padding-left: 5px;
padding-right: 5px;
}
</style>
|
HTML |
Word |
|
|
|