Write Double value in numeric cell with specific format in Apache Poi 3.7

前端 未结 3 1794
广开言路
广开言路 2021-01-02 03:14

I need to write a Double value in a numeric cell using a specific format, i mean, the generated xls must have numeric cells containing Double values like, for example: 8,1.

3条回答
  •  甜味超标
    2021-01-02 03:56

    Do you need to put both values in one cell? Can you split them up into 2 columns? Excel has a built-in "Texts to Columns" function that you should be able to reference that will split an entire column of text strings into multiple columns based on a delimiter (like a comma). In VBA, it looks something like this:

    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
    Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
    :=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
    

    As for your first proposed solution, it is not possible to force Excel to treat something as a number if it is not convertable to a number.

提交回复
热议问题