如何使用Apache POIJava在Excel中的下拉单元格上禁用粘贴Ctrl + V

问题描述

我有代码 ApachePOI ),用户只能在下拉列表中选择一个值,而不能在excel中输入另一个值 (第2列中下拉单元格的行从2到30000开始):

library("ggplot2")
library("reshape2")
library("dplyr")
#Data
test=data.frame(replicate(4,sample(1:10,1000,rep=TRUE)))

melt_data = melt(test,id.vars = NULL)

thresh_data = data.frame("X1" = 2,"X2" = 3,"X3" = 4,"X4" = 5)
thresh_data_melt = melt(thresh_data,id.vars = NULL)
names(thresh_data_melt)[2] <- 'threshold'

#Merge for color
dfjoined <- merge(melt_data,thresh_data_melt,by='variable',all.x=T)
dfjoined$color <- ifelse(dfjoined$value<=dfjoined$threshold,'before','after')
#Plot
ggplot(dfjoined,aes(x = value,fill=color)) + 
  facet_wrap(~variable,scales = "free_x") + 
  geom_histogram() + geom_vline(data=thresh_data_melt,aes(xintercept=threshold,color="red"),linetype="dashed",show.legend = F) 

但是此代码不适用于粘贴(Ctrl + V)。我的问题是:如何使用Apache POI(Java)在excel中的下拉单元格上禁用粘贴(Ctrl + V) protectSheet() 方法锁定整个excel工作表,但对我不起作用。

感谢您的支持。谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)