xslftable的大小以查看插入后是否适合滑动

发布于 2025-02-09 21:08:50 字数 268 浏览 1 评论 0原文

我正在插入n行数的幻灯片节目。有两个问题...

我不知道行的数量,最多有50个,我们允许的,但即使有50个也会脱离幻灯片。

我将添加到每一列的文本也可能很长。

目前,我当前的方法是允许15行,创建一个新的幻灯片来添加下一个15行,依此类推,直到我达到50

。想检查一下它是否从幻灯片中溢出,如果是,我将删除它,制作新的幻灯片,然后将其添加到新表中。

如果可能的话,请保持行高锁定,并允许隐藏任何额外的文本,直到选择单元格(类似于Excel电子表格)。

I am working on a slide show where I insert N number of rows. There are two issues...

I don't know the number of rows, there is a max of 50 we will allow but even 50 will go out of the slide.

The text I will add to each column can also be somewhat long.

Right now, my current approach is allowing 15 rows, creating a new slide to add the next 15, and so on until I hit 50.

What I would prefer to do is get the size of the table and after I finish one row, I would like to check if it is overflowing out of the slide, and if it is, I'll remove it, make a new slide, and add it to the new table.

An alternative approach if possible, is keep the row height locked, and allow any extra text to kinda be hidden until the cell is selected (similar to an excel spreadsheet).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欢烬 2025-02-16 21:08:50

在此处使用类似的方法

apache poi fet font font font量指标

解决方案:

stringlist均可为每行重新播放StringList

int max = 0;
int j = 0;
for (String text : stringList) {
  AttributedString attributedString = new AttributedString(text);
  attributedString.addAttribute(
      TextAttribute.FAMILY, "Avenir Book", 0, text.length());
  attributedString.addAttribute(TextAttribute.SIZE, (float)14);
  TextLayout layout = new TextLayout(attributedString.getIterator(), fontRenderContext);
  Rectangle2D bounds = layout.getBounds();
  max = Math.max(max, (int) Math.ceil((bounds.getWidth() * covertToEmu)
      / (table.getTblGrid().getGridColList().get(j).getW())));
  j++
}

coverttoemu只是一个数字... bands.gets.getwidth()在72 dpi和table.gettblgrid().getGridCollist()中。 getw()(宽度)在EMU中。 72 dpi只是以英寸为单位的像素...每英寸72像素。每英寸的emu是914400。

因此,转换为914400 /72 = 12700。

最大值是“行”的数量,它需要...其余的是硬编码,但是我将我拥有的数据列表分为sublists,然后添加并添加它到每个幻灯片。我知道20行是一个不错的选择,因此,如果它比我创建一个新列表的高度要高,以添加到新的幻灯片中。

还值得注意的是,我正在使用cttable,您可以从xslftable中的方法中获得。

Using a similar approach here

Apache POI get Font Metrics

Solution:

stringList is repopulated for each row

int max = 0;
int j = 0;
for (String text : stringList) {
  AttributedString attributedString = new AttributedString(text);
  attributedString.addAttribute(
      TextAttribute.FAMILY, "Avenir Book", 0, text.length());
  attributedString.addAttribute(TextAttribute.SIZE, (float)14);
  TextLayout layout = new TextLayout(attributedString.getIterator(), fontRenderContext);
  Rectangle2D bounds = layout.getBounds();
  max = Math.max(max, (int) Math.ceil((bounds.getWidth() * covertToEmu)
      / (table.getTblGrid().getGridColList().get(j).getW())));
  j++
}

covertToEmu is just a number...bounds.getWidth() is in 72 dpi and table.getTblGrid().getGridColList().get(j).getW() (the width) is in EMU. 72 dpi is just the pixels in inches...which is 72 pixels per inch. An EMU per inch is 914400.

So convertToEmu is 914400 / 72 = 12700.

The max is the number of "rows" it takes...the rest is kinda hard coded, but I split the list of data I have into sublists and add it to each slide. I know 20 rows is a good fit so if it gets higher than that I create a new list, to add to a new slide.

Also worth noting I am using CTTable, which you can get from a method in XSLFTable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文