OLEDB, Writing Excel cell without leading apostrophe

后端 未结 8 1533
长情又很酷
长情又很酷 2020-12-19 07:51

I\'m writing to Excel file using OLEDB (C#). What I need is just RAW data format.

I\'ve noticed all cells (headers and values) are prefixed by apostrophe (\')

<
相关标签:
8条回答
  • 2020-12-19 08:49

    http://support.microsoft.com/kb/257819 has a statement to the effect that this behaviour might be unavoidable when inserting text into Excel via ADO:

    A caution about editing Excel data with ADO: When you insert text data into Excel with ADO, the text value is preceded with a single quote. This may cause problems later in working with the new data.

    Is the data explicitly text, might it be coerced into a numeric format? (clutching at straws...)

    0 讨论(0)
  • 2020-12-19 08:49

    It may not suit your requirements, particularly if you need to set up formatting in the Excel sheet, but have you considered writing the data out to a CSV file and saving it with an .XLS extension?

    The other thing you could try would be to explicitly set format data types of your target cells in the Excel sheet to type "Text" (as through Format > Cells within Excel) before you attempt to load data. By default, the cells will be of type "General", and the driver may be adding the apostrophe to force your data to be displayed at text.

    0 讨论(0)
提交回复
热议问题