OLEDB, Writing Excel cell without leading apostrophe

后端 未结 8 1588
长情又很酷
长情又很酷 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:24

    Could you just use the Excel DSN? It seems to be pretty ubiquitous. I don't know .NET, so take this with a grain of salt, but here's my connection string for an OLEDB Query straight from a stock table:

    "Provider=MSDASQL.1;Persist Security Info=True;Extended Properties
    =""DSN=Excel Files;DBQ=" & filePath & "\" & fileName &
    ";DriverId=1046;MaxBufferSize=2048;PageTimeout=5;"""
    

    And I used this basic INSERT statement:

    INSERT INTO rngOutput VALUES (1, 'ABC', '$1.00', 1300)
    

    When I did this, I didn't have any apostrophes in my data range. I'm also using Excel 2007, and I see you're using Excel 8.0 as your driver?

    Hopefully that nudges you toward a solution!

提交回复
热议问题