Good morning all,
First of all, thank you for taking the time to read my post, its my first, please be gentle :) I have created a windows form using VS2019 /c#. The user inserts the data and hits "insert" which then saves the data as a CSV file. Tableau then reads the CSV file, which all works. However I need the date format as yyyy-MM-dd. I cannot for the life of me get that to work. It always saves as MM-dd-yyyy. I am using a datetimepicker. Please see my code below for more info, and thank you so much for your help.
Excel.Workbook xlworkbook;
Excel.Worksheet xlworksheet;
object misValue = System.Reflection.Missing.Value;
xlworkbook = xlap.Workbooks.Add(misValue);
xlworksheet = (Excel.Worksheet)xlworkbook.Worksheets.get_Item(1);
Excel.Sheets worksheets = xlworkbook.Worksheets;
worksheets[3].Delete();
worksheets[2].Delete();
xlworksheet.Cells[1, 1] = textBox1.Text;
xlworksheet.Cells[1, 2] = dateTimePicker1.Value.ToString("yyyyMMdd");
xlworksheet.Cells[1, 3] = textBox2.Text;
xlworksheet.Cells[1, 4] = textBox3.Text;
xlworksheet.Cells[1, 5] = textBox4.Text;
xlworksheet.Cells[1, 6] = textBox5.Text;
xlworksheet.Cells[1, 7] = textBox6.Text;
xlworksheet.Cells[1, 8] = textBox7.Text;
xlworksheet.Cells[1, 9] = textBox8.Text;
xlworksheet.Cells[1, 10] = textBox9.Text;
xlworksheet.Cells[1, 13] = textBox10.Text;
xlworksheet.Cells[1, 11] = comboBox1.Text;
xlworksheet.Cells[1, 12] = comboBox2.Text;
xlworkbook.SaveAs(@"\\172.21.4.14\BusinessLanding\BusinessLanding_Sync\operations_sync\FlightPlanning\savings_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv", Excel.XlFileFormat.xlCSVWindows);
xlworkbook.Close(true);
xlap.Quit();
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
}