Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: samples/total/client/CSVReader.dart

Issue 10635015: Delete proxy and total samples, which have bit-rotted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/total/client/Adminz.js ('k') | samples/total/client/Cell.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 class CSVReader extends Reader {
6
7 CSVReader() : super() { }
8
9 void loadSpreadsheet(Spreadsheet spreadsheet, List<String> csv) {
10 Style defaultFormat = new Style();
11 // Hardcode $1000.12 format for now
12 Style currencyFormat = defaultFormat.setNumericFormatByIndex(4);
13 // Use % format for the interest rate
14 Style percentageFormat = defaultFormat.setNumericFormatByIndex(8);
15 for (int row = 0; row < csv.length; row++) {
16 List<String> cells = StringUtils.split(csv[row], ",".charCodeAt(0));
17 for (int col = 0; col < cells.length; col++) {
18 String formula = cells[col];
19 RowCol rowCol = new RowCol(row + 1, col + 1);
20 CellLocation location = new CellLocation(spreadsheet, rowCol);
21 spreadsheet.execute(new SetCellContentsCommand(location, formula));
22 if ((row == 1 && (col == 0 || col == 3)) || (row > 2 && col > 0)) {
23 spreadsheet.setCellStyle(location.rowCol, currencyFormat);
24 } else if (row == 2 && col == 2) {
25 spreadsheet.setCellStyle(location.rowCol, percentageFormat);
26 } else {
27 spreadsheet.setCellStyle(location.rowCol, defaultFormat);
28 }
29 }
30 }
31 }
32
33 List<String> makeExample(String id) {
34 int years = 30;
35 int payments = years * 12;
36 List<String> csv = new List<String>(payments + 4);
37 csv[0] = "\"Loan Amount\",\"Interest Rate\",\"Years\",\"Monthly Payment\"";
38 csv[1] = "375000,.05375,${years},\"=ROUND((R2C1*((R2C2/12)/(1-POWER((1+(R2C2 /12)),"
39 + "(-12*R2C3))))),2)\"";
40 csv[2] = "\"Payment #\",\"Balance\",\"Interest\",\"Principal\"";
41 csv[3] = "1,\"=R2C1\",\"=(RC[-1]*R2C2)/12\",\"=R2C4-RC[-1]\"";
42 for (int i = 4; i < payments + 3; i++) {
43 csv[i] = "\"=R[-1]C+1\",\"=R[-1]C-R[-1]C[2]\",\"=(RC[-1]*R2C2)/12\",\"=R2C 4-RC[-1]\"";
44 }
45 csv[payments + 3] = "\"Totals\",\"=C364+D364\",\"=SUM(C4:C363)\",\"=SUM(D4:D 363)\"";
46 return csv;
47 }
48 }
OLDNEW
« no previous file with comments | « samples/total/client/Adminz.js ('k') | samples/total/client/Cell.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698