简体   繁体   English

使用Apache POI可以阻止用户复制格式吗?

[英]Using Apache POI can I stop users copying formatting?

I have made an excel sheet which is generated by Java. 我制作了一个由Java生成的excel表。 The cells can only accept certain values, depending on data validation done against lists on a separate sheet. 单元格只能接受某些值,具体取决于对单独工作表上的列表进行的数据验证。

This all works great, but if a user copies some values from another cell and pastes it into the cell it avoids validation... is there any way to prevent this? 这一切都很好,但如果用户从另一个单元格复制一些值并将其粘贴到单元格中,则可以避免验证...有什么方法可以防止这种情况发生吗?

You can do this by setting data format for that cell. 您可以通过设置该单元格的数据格式来完成此操作。

style = wb.createCellStyle();
style.setDataFormat(wb.createDataFormat().getFormat("0.000%"));

which will percentage value. 这将是百分比值。 For documentation goto: Apache HSSF Doc 有关文档goto: Apache HSSF Doc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM