-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
设值workbook或者sheet的format cells为text而不是general #382
Labels
Comments
目前没有可以直接设置的方法,不过可以简单修改即可实现。 设置列为文本属性是通过NumFmt实现的,所以首先我们需要添加一个code为‘@’的NumFmt
第二步需要自定义一个WorksheetWriter并将上面得到的txtStyle写入col节点上
好了,现在你可以使用这个MyXMLWorksheetWriter 来实现文本格式了,整体代码如下
当然,如果此功能仅少量范围使用则不需要提出一个类
如果要设置整个worksheet均为文本则需要特殊处理,xlsx格式共包含16384列,writeCol方法的min和max参数即为列下标,所以我们只需要将最大下标改为16384即可,需要注意的是必须在写有效范围的最后一个列时将max改为16384,你可以使用 columns[columns.length - 1].getRealColIndex()与min进行比较,相同即为最后一列。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
有没有办法把整个worksheet或者整个sheet的format cell设值为Text (或者定义例如10个column的1000个row也行)
测试了使用setStyleProcessor只能把有数据的设值为Text
The text was updated successfully, but these errors were encountered: