fixed code duplication and moved spreadsheet code into package charts.spreadsheet