aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Documents
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-10-07 13:05:29 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-10-07 13:05:29 +0300
commita2fcd642758c9506188160856a0f9cc0dc48be38 (patch)
tree10ad2cd62dff0d96e70a56e484b54498aaa2d7d9 /Software/Visual_Studio/Tango.Documents
parent613be9fa6348139fd00ab8144885356ba36f5595 (diff)
downloadTango-a2fcd642758c9506188160856a0f9cc0dc48be38.tar.gz
Tango-a2fcd642758c9506188160856a0f9cc0dc48be38.zip
Working on RML module.
Diffstat (limited to 'Software/Visual_Studio/Tango.Documents')
-rw-r--r--Software/Visual_Studio/Tango.Documents/ExcelReader.cs9
-rw-r--r--Software/Visual_Studio/Tango.Documents/ExcelWriter.cs22
2 files changed, 25 insertions, 6 deletions
diff --git a/Software/Visual_Studio/Tango.Documents/ExcelReader.cs b/Software/Visual_Studio/Tango.Documents/ExcelReader.cs
index b212678ae..3d6b37445 100644
--- a/Software/Visual_Studio/Tango.Documents/ExcelReader.cs
+++ b/Software/Visual_Studio/Tango.Documents/ExcelReader.cs
@@ -67,7 +67,7 @@ namespace Tango.Documents
PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
- for (int rowIndex = firstRowIndex; rowIndex < rowCount; rowIndex++)
+ for (int rowIndex = firstRowIndex; rowIndex < rowCount + 1; rowIndex++)
{
Row row = GetRow(currWorksheet, rowIndex);
if (row == null)
@@ -82,7 +82,7 @@ namespace Tango.Documents
Cell cell = cells[cellIndex] as Cell;
String value = CellValue(cell);
- properties[cellIndex].SetValue(newObj, value);
+ properties[cellIndex].SetValue(newObj, Convert.ChangeType(value, properties[cellIndex].PropertyType));
}
results.Add(newObj);
@@ -330,8 +330,9 @@ namespace Tango.Documents
/// <returns></returns>
private Row GetRow(Worksheet worksheet, int rowIndex)
{
- var row = worksheet.GetFirstChild<SheetData>().
- Elements<Row>().Where(r => r.RowIndex == rowIndex).FirstOrDefault();
+ var sheetData = worksheet.GetFirstChild<SheetData>();
+ var elements = sheetData.Elements<Row>();
+ var row = elements.Where(r => r.RowIndex == rowIndex).FirstOrDefault();
return row;
}
diff --git a/Software/Visual_Studio/Tango.Documents/ExcelWriter.cs b/Software/Visual_Studio/Tango.Documents/ExcelWriter.cs
index 613bbd90f..63c04bce9 100644
--- a/Software/Visual_Studio/Tango.Documents/ExcelWriter.cs
+++ b/Software/Visual_Studio/Tango.Documents/ExcelWriter.cs
@@ -52,9 +52,12 @@ namespace Tango.Documents
{
var item = list[i];
+ var last_row = sheetData.Elements<Row>().Last();
+
Row newRow = new Row();
+ newRow.RowIndex = last_row.RowIndex + 1;
- sheetData.InsertAfter(newRow, sheetData.Elements<Row>().Last());
+ sheetData.InsertAfter(newRow, last_row);
foreach (var prop in props)
{
@@ -77,7 +80,22 @@ namespace Tango.Documents
cell.CellReference = cellReference;
}
cell.CellValue = new CellValue(value.ToString());
- cell.DataType = CellValues.String;
+
+ cell.DataType = CellValues.Number;
+
+ if (value is String)
+ {
+ cell.DataType = CellValues.String;
+ }
+ else if (value is DateTime)
+ {
+ cell.DataType = CellValues.Date;
+ }
+ else if (value is Boolean)
+ {
+ cell.DataType = CellValues.Boolean;
+ }
+
row.Append(cell);
}