Using EPPlus Excel - How to ignore excel error checking or remove green tag on top left of the cell

前端 未结 7 1705
孤街浪徒
孤街浪徒 2020-12-13 16:29

I use EPPlus to export excel 2007 file. The file can export normally but i have some problem with setting column format. My string column with numeric style (Purchase Order

7条回答
  •  猫巷女王i
    2020-12-13 17:12

    Yes, EPPlus cannot treat the data as number depending on its value. If your underlying data is in string datatype then you can try to get it in numeric datatype. e.g. If you get data from a stored procedure try to get it as a numeric value. There was a problem we had when we implemented it. We used the same stored procedure for Web and to generate excel. Web UI needed it to be in string datatype for formatting reasons and EPPlus obviously needs it to be in the numeric format so that it can show it as a number. The solution was to convert the required data to numeric when exporting to excel using EPPlus in C# code. So you need to write a conversion function to convert required fields in the DataTable into datatype you require (or implement conversion logic using cast or convert in your Stored Procedure).

    In summary: - Write a C# function to convert datatypes of columns in the DataTable you obtain before sending it as excel sheet using EPPlus.

提交回复
热议问题