OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Get formatted value from worksheet cell in ExcelJS

  • Thread starter Thread starter prototype
  • Start date Start date
P

prototype

Guest
Is there a way to get the formatted numerical value from a worksheet cell in ExcelJS? In the Excel workbook the cell formula results in value is 5.726027397260274, has a number format of "#,###.0" , and displays as "5.7".

But in Excel JS, workbook.getWorksheet("slide1").getCell('Q4').text returns "5.726027397260274". Does ExcelJS have a way to resolve number formats to retrieve formatted values?

enter image description here

Code:
{
 text: "5.726027397260274",
  _value:   {
    "model": {
        "address": "Q4",
        "value": 5.726027397260274,
        "type": 2,
        "style": {
            "numFmt": "#,##0.0",
            "font": {
                "size": 11,
                "color": {
                    "theme": 1
                },
                "name": "Calibri",
                "family": 2,
                "scheme": "minor"
            },
            "border": {
                "left": {
                    "style": "thin",
                    "color": {
                        "indexed": 64
                    }
                },
                "right": {
                    "style": "thin",
                    "color": {
                        "indexed": 64
                    }
                },
                "top": {
                    "style": "thin",
                    "color": {
                        "indexed": 64
                    }
                },
                "bottom": {
                    "style": "thin",
                    "color": {
                        "indexed": 64
                    }
                }
            },
            "fill": {
                "type": "pattern",
                "pattern": "solid",
                "fgColor": {
                    "argb": "FFFFFF00"
                },
                "bgColor": {
                    "indexed": 64
                }
            },
            "alignment": {
                "horizontal": "center"
            }
        }
        
    }
  }
}

<p>Is there a way to get the formatted numerical value from a worksheet cell in ExcelJS? In the Excel workbook the cell formula results in value is 5.726027397260274, has a number format of "#,###.0" , and displays as "5.7".</p>
<p>But in Excel JS, <code>workbook.getWorksheet("slide1").getCell('Q4').text</code> returns "5.726027397260274". Does ExcelJS have a way to resolve number formats to retrieve formatted values?</p>
<p><a href="https://i.sstatic.net/b2vZ4XUr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/b2vZ4XUr.png" alt="enter image description here" /></a></p>
<pre class="lang-json prettyprint-override"><code>{
text: "5.726027397260274",
_value: {
"model": {
"address": "Q4",
"value": 5.726027397260274,
"type": 2,
"style": {
"numFmt": "#,##0.0",
"font": {
"size": 11,
"color": {
"theme": 1
},
"name": "Calibri",
"family": 2,
"scheme": "minor"
},
"border": {
"left": {
"style": "thin",
"color": {
"indexed": 64
}
},
"right": {
"style": "thin",
"color": {
"indexed": 64
}
},
"top": {
"style": "thin",
"color": {
"indexed": 64
}
},
"bottom": {
"style": "thin",
"color": {
"indexed": 64
}
}
},
"fill": {
"type": "pattern",
"pattern": "solid",
"fgColor": {
"argb": "FFFFFF00"
},
"bgColor": {
"indexed": 64
}
},
"alignment": {
"horizontal": "center"
}
}

}
}
}
</code></pre>
 

Latest posts

U
Replies
0
Views
1
user3658366
U
G
Replies
0
Views
1
Giampaolo Levorato
G
M
Replies
0
Views
1
Marcelo Rodrigo Nascimento
M
Top