Q:

Insert integers into excel sheet

Inserting data using oledb into an excel sheet, integers are only displayed as integers:

I already tried to change the properties of the following connection string:
string szConnectionString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + myFilePath + "';Extended Properties=\"Excel 12.0;HDR=YES;Readonly=False;\"";

Additionally I tried to create a new sheet/table with data types:
cmd.CommandText = "CREATE TABLE [data3] (quarter VARCHAR, value INT);";

Following my current code inserting data:
cmd.CommandText = "CREATE TABLE [data3] (quarter VARCHAR, value INT);";
cmd.ExecuteNonQuery();

cmd.CommandText = "INSERT INTO [data3$]([quarter ],[value]) VALUES(?,?)";
cmd.Parameters.AddWithValue("@p1", "2018.06");
cmd.Parameters.AddWithValue("@p2", 13); // <-- INT
cmd.ExecuteNonQuery();

My expectation is that the data are inserted into excel correctly, meaning in the correct format.

A:

I ran this code and had no issues after changing it to the following:
cmd.CommandText = "CREATE TABLE [data3] (quarter VARCHAR, value INT);";
cmd.ExecuteNonQuery();

cmd.CommandText = "INSERT INTO [data3$]([quarter],[value]) VALUES(@Q1,@V1)";
cmd.Parameters.AddWithValue("@Q1", "2018.06");
cmd.Parameters.Add("@V1", SqlDbType.Int);
cmd.Parameters["@V1"].Value = 13;
cmd.ExecuteNonQuery();

I made a few changes and forced the value parameter to be an integer. 

