How can I get the reflectance of an image numerically?

I want to get the reflectance of the image acquired by sentinel-2 and make it a file.

Specifically, I would like to collect the reflectance in the specified range into a file so that it can be processed by the program.

How can I get the reflectance?

If you use SNAP the values are already shown as reflectances.
You just need to open the MTD_MSIL1C.xml in the product folder, not directly the jp2 files.
You can then export those values in several ways and formats.

If you wan’t to work with the jp2 files directly you need to devide the values in those by 10000. This value is the so called QUANTIFICATION_VALUE and is stored on the MTD_MSIL1C.xml.

Thank you for your reply.

I want to create a file with the reflectance displayed by SNAP.
Should I open MTD_MSIL1C.xml with SNAP?

Yes, and then you can export as CSV or NetCDF or GeoTiff.
But in some formats (e.g.NetCDF) they are also stored as raw values.