使用 java“getNamedRange(“SOME_VARIABLE”)”清空 Excel 单元格
我的项目我必须使用java编码修改excel文件。 我的要求是完全清空具有字符串值“SOME_VARIABLE”的单元格。
book.getNamedRange("SOME_VARIABLE").remove();
上面的代码正确吗?我尝试过这个,但它不起作用。所以我尝试编写一个代码来检查我是否在正确的工作簿中删除它,就像如果工作簿不包含“SOME_VARIABLE”那么它应该通知我。该代码如下:
if(book.getNamedRange("SOME_VARIABLE")== null)
{record("the"+SOME_VARIABLE+" is not found");}
else{
book.getNamedRange("SOME_VARIABLE").remove();}
我走的路正确吗?由于我是新来处理这个 excelEngine 的,所以我很挣扎。请朋友们帮助我。
I am project i have to modify the excel file using java codings.
My requirement is to empty the cell completely which has the string value "SOME_VARIABLE".
book.getNamedRange("SOME_VARIABLE").remove();
Is the above code a right one. I tried with this but it is not working. So I tried to write a code to check Am I deleting it in a right WORKBOOK, like if the workbook does not contain "SOME_VARIABLE" then it should inform me . That code is as follows:
if(book.getNamedRange("SOME_VARIABLE")== null)
{record("the"+SOME_VARIABLE+" is not found");}
else{
book.getNamedRange("SOME_VARIABLE").remove();}
Am I going in a right path ? As i am new to handle this excelEngine I am strugling. Kindly help me friends.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您提供的代码将删除命名范围的单元格(ref)
SOME_VARIABLE
。如果要检查单元格的
值
,则需要find
(ref) 包含SOME_VARIABLE
的单元格。The code you provided will delete the cells of the Named Range (ref)
SOME_VARIABLE
.If you want to check the
value
of the cell, you need tofind
(ref) the cells that containsSOME_VARIABLE
.