如何将 Excel 单元格中的数字字符串作为字符串(不是数字)读取? [英] How can I read numeric strings in Excel cells as string (not numbers)?

查看:37
本文介绍了如何将 Excel 单元格中的数字字符串作为字符串(不是数字)读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我有一个包含以下内容的 excel 文件:

  1. I have excel file with such contents:

  • A1:SomeString

  • A1: SomeString

A2:2

所有字段都设置为字符串格式.

All fields are set to String format.

当我使用 POI 在 java 中读取文件时,它告诉我 A2 是数字单元格格式.

When I read the file in java using POI, it tells that A2 is in numeric cell format.

如何将值读取为字符串?

What can I do to read the value as string?

推荐答案

我遇到了同样的问题.我在读取字符串值之前做了 cell.setCellType(Cell.CELL_TYPE_STRING); ,无论用户如何格式化单元格都解决了问题.

I had same problem. I did cell.setCellType(Cell.CELL_TYPE_STRING); before reading the string value, which solved the problem regardless of how the user formatted the cell.

这篇关于如何将 Excel 单元格中的数字字符串作为字符串(不是数字)读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆