Excel在CSV导出中添加额外的报价 [英] Excel adds extra quotes on CSV export

查看:106
本文介绍了Excel在CSV导出中添加额外的报价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近创建了一个应用程序,该应用程序通过CSV将项目添加到数据库中.添加项目后,我意识到很多值都不需要多余的引号(),这使我的订购变得混乱.

I've recently created an application which adds items to a Database by CSV. After adding items I realized that lots of my values had extra quotes (") that weren't needed and this was messing up my ordering.

问题在于,当从Excel导出到CSV时,Excel会将多余的引号添加到我所有已带有引号的值中.我已经显示出以下差异:

The problem is that when exporting to a CSV from Excel, Excel adds extra quotes to all of my values that already have a quote in them. I've shown the difference below:

原始产品:可逆电钻1/2"6.3A

出口商品:可逆电钻1/2""6.3"

请注意:CSV导出会添加三(3)个额外的引号().两端加两个引号,一个在原始预期引号之后.

是否可以在Excel文件/列上更改设置或设置格式属性?还是我必须忍受它并在添加到数据库之前在我的后端代码中删除这些引号?

Is there a setting I can change, or a formatting property I can set on the Excel File/Column? Or do I have to live with it and remove these quotes in my back-end code before adding them to the Database?

推荐答案

这是完全正常的.添加外部引号,因为这是一个字符串.内引号被加倍以逃避它.例如,您在SQL查询中会看到相同的内容.使用TextFieldParser类可以为您自动尝试真正的框架代码解析.

This is entirely normal. The outer quotes are added because this is a string. The inner quote is doubled to escape it. Same kind of thing you'd see in a SQL query for example. Use the TextFieldParser class to have tried and true framework code care of the parsing of this for you automatically.

这篇关于Excel在CSV导出中添加额外的报价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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