0

I open a xlsx file that contains names and description of automation test. Then I place the value of 'pass' or 'fail' into the respective cell for a test. Then I write back to the xlsx file. When I open the file to look at the results I notice several cells with test names missing. There is no error message as far as the program go it believes everything is working fine. here is the code i use for editing the excel file. Does anyone know why its doing this?

function writeToExcel(value)
{
  var Excel = require('exceljs');
  var workbook = new Excel.Workbook();
  workbook.xlsx.readFile('reports/Mobile Test.xlsx').then(function()
  {
      var worksheet = workbook.getWorksheet('TestCases');
      worksheet.getCell("E27").value = value;
      workbook.xlsx.writeFile('reports/Mobile Test.xlsx');
  });
}
James
  • 129
  • 1
  • 7

2 Answers2

0

Right now, it seems that if a null value is passed into the function, the value for the cell you are looking for will be set to null, effectively deleting it. This would make sense with what you were saying about how only the areas that are being deleted are the ones that aren't edited since that will most probably pass in a null value. You should try to do a null check on the value passed in.

OmegaNalphA
  • 610
  • 1
  • 6
  • 17
  • the values is sent as pass or fail and that cell actually updates, its other cells that are being effected. say worksheet.getCell("E27").value = value; that sets cell E27 to 'pass' but for some reason cells like C35= 'test1' C45='test23' C64='test Name'... values are being are being erased. – James Aug 08 '17 at 21:56
0

Well after looking at what the cells that where messing had in common I noticed all the cells that were missing have words inside (parentheses) the cells without parentheses were still there so somethings happening when trying to write parentheses, but I don't need the parentheses so I just took them out and it worked fine.

James
  • 129
  • 1
  • 7