How to multiple c# form entries into one excel document? -


i have code stores value of form excel spreadsheet, however, when second person's details entered , form exported, new spreadsheet created, whereas want add second line existing spreadsheet. can work out how make go second line, how stop opening new spreadsheet?

the code is:

if (runonce)         {             microsoft.office.interop.excel.application xla = new microsoft.office.interop.excel.application { };         };          #region validation          int years = datetime.now.year - dateofbirthpicker.value.year;         if (dateofbirthpicker.value.addyears(years) > datetime.now) years--;           if (years < 18 || years > 21  )         {             error = true;             messagebox.show("you must on 18 , under 21 apply elite university");         }           if (string.isnullorwhitespace(titlecombobox.text))         {             error = true;             messagebox.show("please select title");         }          if (string.isnullorwhitespace(firstnametextbox.text))         {             error = true;             messagebox.show("please enter first name");         }          if (string.isnullorwhitespace(lastnametextbox.text))         {             error = true;             messagebox.show("please enter last name");         }          if (string.isnullorwhitespace(dateofbirthpicker.text))         {             error = true;             messagebox.show("please select date of birth");         }          if (string.isnullorwhitespace(sexcombobox.text))         {             error = true;             messagebox.show("please select sex");         }          if (string.isnullorwhitespace(housenumbertextbox.text))         {             error = true;             messagebox.show("please enter house number");         }          if (string.isnullorwhitespace(streetnametextbox.text))         {             error = true;             messagebox.show("please enter street name");         }          if (string.isnullorwhitespace(towntextbox.text))         {             error = true;             messagebox.show("please select town");         }          if (string.isnullorwhitespace(countytextbox.text))         {             error = true;             messagebox.show("please enter county");         }          if (string.isnullorwhitespace(postcodetextbox.text))         {             error = true;             messagebox.show("please enter postcode");         }          if (string.isnullorwhitespace(emailaddresstextbox.text))         {             error = true;             messagebox.show("please enter valid email address");         }         // if (string.isnullorwhitespace(alevelpassestextbox.text))        // {         //    error = true;          //   messagebox.show("please enter number of a-level passes");       //  }        // else         //{        //     int alevelpasses = convert.toint32(alevelpassestextbox.text);        // }          if (string.isnullorwhitespace(subject1textbox.text))         {             error = true;             messagebox.show("please enter first subject choice");         }          if (string.isnullorwhitespace(subject2textbox.text))         {             error = true;             messagebox.show("please enter second subject choice");         }         //  if (string.isnullorwhitespace(donationamounttextbox.text))        // {        //     error = true;        //     messagebox.show("please enter donation ammount");        // }        // else        // {        //     int donationamount = convert.toint32(donationamounttextbox.text);         //}        //  if (alevelpasses < 3)        // {        //     error = true;        //     messagebox.show("you must have minimum of 3 a-level passes apply elite university");        // }         // if (donationamount< 10)        // {         //    error = true;         //    messagebox.show("you must donate more £10");         //}         #endregion          if (!error & runonce)         {              workbook wb = xla.workbooks.add(xlsheettype.xlworksheet);             worksheet ws = (worksheet)xla.activesheet;              xla.visible = true;              ws.cells[1, 1] = "title";             ws.cells[1, 2] = "first name";             ws.cells[1, 3] = "last name";             ws.cells[1, 4] = "date of birth ";             ws.cells[1, 5] = "sex";             ws.cells[1, 6] = "house number ";             ws.cells[1, 7] = "street name";             ws.cells[1, 8] = "town";             ws.cells[1, 9] = "county";             ws.cells[1, 10] = "postcode";             ws.cells[1, 11] = "email address";             ws.cells[1, 12] = "number of a-level passes";             ws.cells[1, 13] = "subject1";             ws.cells[1, 14] = "subject2";             ws.cells[1, 15] = "subject3";               ws.cells[2, 1] = titlecombobox.text;             ws.cells[2, 2] = firstnametextbox.text;             ws.cells[2, 3] = lastnametextbox.text;             ws.cells[2, 4] = dateofbirthpicker.text;             ws.cells[2, 5] = sexcombobox.text;             ws.cells[2, 6] = housenumbertextbox.text;             ws.cells[2, 7] = streetnametextbox.text;             ws.cells[2, 8] = towntextbox.text;             ws.cells[2, 9] = countytextbox.text;             ws.cells[2, 10] = postcodelabel.text;             ws.cells[2, 11] = emailaddresstextbox.text;             ws.cells[2, 12] = alevelpassestextbox.text;             ws.cells[2, 13] = subject1textbox.text;             ws.cells[2, 14] = subject2textbox.text;             runonce = true;          }          if (!runonce)         {              workbook wb = xla.workbooks.add(xlsheettype.xlworksheet);             worksheet ws = (worksheet)xla.activesheet;              xla.visible = true;              ws.cells[1, 1] = "title";             ws.cells[1, 2] = "first name";             ws.cells[1, 3] = "last name";             ws.cells[1, 4] = "date of birth ";             ws.cells[1, 5] = "sex";             ws.cells[1, 6] = "house number ";             ws.cells[1, 7] = "street name";             ws.cells[1, 8] = "town";             ws.cells[1, 9] = "county";             ws.cells[1, 10] = "postcode";             ws.cells[1, 11] = "email address";             ws.cells[1, 12] = "number of a-level passes";             ws.cells[1, 13] = "subject1";             ws.cells[1, 14] = "subject2";             ws.cells[1, 15] = "subject3";               ws.cells[2, 1] = titlecombobox.text;             ws.cells[2, 2] = firstnametextbox.text;             ws.cells[2, 3] = lastnametextbox.text;             ws.cells[2, 4] = dateofbirthpicker.text;             ws.cells[2, 5] = sexcombobox.text;             ws.cells[2, 6] = housenumbertextbox.text;             ws.cells[2, 7] = streetnametextbox.text;             ws.cells[2, 8] = towntextbox.text;             ws.cells[2, 9] = countytextbox.text;             ws.cells[2, 10] = postcodelabel.text;             ws.cells[2, 11] = emailaddresstextbox.text;             ws.cells[2, 12] = alevelpassestextbox.text;             ws.cells[2, 13] = subject1textbox.text;             ws.cells[2, 14] = subject2textbox.text;          }      } 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -