使用HTML页面的CSS格式将标签显示为Excel [英] Display tag export to excel with the css formatting of the HTML page

查看:239
本文介绍了使用HTML页面的CSS格式将标签显示为Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Web应用程序中使用显示标签.我可以成功地将显示标签显示的数据导出到excel.

I am using display tag in my web application. I am successfully able to export the data displayed by display tag to excel.

问题是我还希望将标题和数据行样式以及CSS包含在导出的excel中.

The problem is I also want the header and data row styles and css to be included in the exported excel.

例如标题行是带有灰色背景的粗体,数据行中的列根据值而着色.

e.g. Header row is bold with gray background and columns in data rows are colored depending on the value.

但是,这并没有导出到excel.

But this is not getting exported to excel.

-

下面是我的JSP中的显示标签代码.正确显示了该列表,并将所有css正确应用于标题和数据行.

Below is the display tag code in my JSP. The list is shown properly with all the css applied to headers and data rows properly.

我还可以将数据导出到excel中.

I can also export the data into the excel.

<display:table name="userList"  pagesize="20"  class="listingTable" keepStatus="true" 
cellpadding="0px"  cellspacing="0px"  id="user" export='true' requestURI="">
<display:setProperty name="export.decorated" value="true" />
<display:setProperty name="export.excel.filename" value="User List.xls" />
<display:column titleKey="user.firstname" property="firstname"></display:column>
<display:column titleKey="user.lastname" property="lastname"></display:column>
<display:column titleKey="user.email" property="email"></display:column>
<display:setProperty name="paging.banner.item_name" value="User" />
<display:setProperty name="paging.banner.items_name" value="Users" />

我正在使用默认的展示广告代码样式表,并对它做了一些小的更改.

I am using the default display tag style sheet with some minor changes to it.

请帮助.

推荐答案

CSS样式必须直接应用于需要样式化的每个元素.因此,对于带有灰色背景的粗体标题行,您需要以下css:

CSS Styles must be directly applied to each element that needs styling. So for a bold header row with a grey background, you need the following css:

th { background-color: grey-25-percent; font-weight: bold }

(或使用theadthead tr代替th)

displaytag还将某些类应用于奇数/偶数行,已排序的行以及其他一些类. 查看此页面以获取更多详细信息.

displaytag also applies some classes to odd/even rows, sorted rows, and a few others. See this page for more details.

此外,Excel只能使用56种不同的颜色,因此,如果要字体颜色或背景色,则必须使用Excel可以接受的颜色. 请参阅本文以获取与Excel兼容的所有颜色.

Also, Excel can only use 56 different colors, so if you want a font color or background color, you must use a color that Excel can accept. See this article for the full range of Excel compatable colors.

以下是可接受的颜色的简短列表:AQUA,BLACK,BLUE,BLUE_GREY,BRIGHT_GREEN,BROWN,CORAL,CORNFLOWER_BLUE,DARK_BLUE,DARK_GREEN,DARK_RED,DARK_TEAL,DARK_YELLOW,GOLD,GREEN_25_PER_CENT,GREY_40,PERCENT,GREY_40靛蓝,薰衣草,LEMON_CHIFFON,LIGHT_BLUE,LIGHT_CORNFLOWER_BLUE,LIGHT_GREEN,LIGHT_ORANGE,LIGHT_TURQUOISE,LIGHT_YELLOW,LIME,MAROON,OLIVE_GREEN,ORANGE,ORCHID,PALE_BLUE,BLUE_BLUE,SEK,PREE紫罗兰色,白色,黄色

Here is a short list of acceptable colors: AQUA, BLACK, BLUE, BLUE_GREY, BRIGHT_GREEN, BROWN, CORAL, CORNFLOWER_BLUE, DARK_BLUE, DARK_GREEN, DARK_RED, DARK_TEAL, DARK_YELLOW, GOLD, GREEN, GREY_25_PERCENT, GREY_40_PERCENT, GREY_50_PERCENT, GREY_80_PERCENT, INDIGO, LAVENDER, LEMON_CHIFFON, LIGHT_BLUE, LIGHT_CORNFLOWER_BLUE, LIGHT_GREEN, LIGHT_ORANGE, LIGHT_TURQUOISE, LIGHT_YELLOW, LIME, MAROON, OLIVE_GREEN, ORANGE, ORCHID, PALE_BLUE, PINK, PLUM, RED, ROSE, ROYAL_BLUE, SEA_GREEN, SKY_BLUE, TAN, TEAL, TURQUOISE, VIOLET, WHITE, YELLOW

这篇关于使用HTML页面的CSS格式将标签显示为Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆