帆软:单元格超过一定长度显示省略号(...),鼠标悬浮显示全部内容

1. 描述

在实际应用中,有的单元格可能内容较多,如何能做到内容超出一定长度显示省略号(...),当鼠标移动到单元格的时候,显示全部内容呢?

222

 

2. 解决方案

2.1 方法一(直接用 FineReport 公式实现)

1)在A2单元格输入一段文字如:对单元格设置超过一定长度页面显示...,鼠标放上去显示全部值。

2)在单元格形态,给单元格设置公式形态,if(len($$$)>5,left($$$,5)+'...',$$$),当单元格内容长度超过 5 位时,显示内容前 5 位加上省略号(...),当单元格内容长度小于等于 5 位时,显示全部内容:

3)在单元格其他属性,内容提示设置为=$$$,如下图:

设置完成后,即可实现效果。

2.2 方法二(JS 实现)

 

1)在 A2 单元格输入一段文字如:对单元格设置超过一定长度页面显示...,鼠标放上去显示全部值。

2)点击模板>模板web>分页预览设置,添加加载结束事件,如下图:

JS 代码如下:

//获取到 td 中的字符串,截取字符串
$("td[title^=cut]").each(function(){
//获取属性的值
var str = $(this).attr('title');
//定义分隔符号
var length = parseInt(str.split(":")[1]);
//判断长度
if($(this).text().length > length){
      $(this).attr('title',$(this).text());
      $(this).text($(this).text().substring(0,length)+'...');
      }else
      $(this).removeAttr('title');
      })

3)在 A2 单元格其他属性,内容提示输入:cut_+A2+:+5,cut_+A2+:+5中,A2 是单元格的位置;5 是显示的个数;冒号是英文符号,且前后需要使用+进行拼接,如下图:

设置完成后,即可实现效果。

 

 

PS:使用第一种方式最简单,但是导出excel内容也回带"...",所以使用第二种方式(JS 实现)

posted @   silentmuh  阅读(2883)  评论(0编辑  收藏  举报
Live2D
欢迎阅读『帆软:单元格超过一定长度显示省略号(...),鼠标悬浮显示全部内容』
  1. 1 Walk Thru Fire Vicetone
  2. 2 爱你 王心凌
  3. 3 Inspire Capo Productions - Serenity
  4. 4 Welcome Home Radical Face
  5. 5 粉红色的回忆 李玲玉
Welcome Home - Radical Face
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : Ben P. Cooper

作曲 : Cooper

Sleep don't visit, so I choke on sun

And the days blur into one

And the backs of my eyes hum with things I've never done

Sheets are swaying from an old clothesline

Was never much but we've made the most

Welcome home

Ships are launching from my chest

Some have names but most do not

If you find one,please let me know what piece I've lost

Heal the scars from off my back

I don't need them anymore

You can throw them out or keep them in your mason jars

I've come home

All my nightmares escaped my head

Bar the door, please don't let them in

You were never supposed to leave

Now my head's splitting at the seams

And I don't know if I can

Here, beneath my lungs

I feel your thumbs press into my skin again

点击右上角即可分享
微信分享提示