- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using Excel;
using FPCLib.Models.Broadcasts;
namespace ExcelReadTests.Model.Путевка
{
public class MyExcel : IDisposable
{
private readonly DataTable table;
public MyExcel(string putevkaFileName)
{
table = ReadToTable(putevkaFileName);
}
internal DataTable ReadToTable(string excelFileName)
{
var stream = File.Open(excelFileName, FileMode.Open, FileAccess.Read);
var excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
return excelReader.AsDataSet().Tables[0];
}
public bool IsTvc()
{
if (table.Columns.Count == 10)
return true;
return false;
}
public bool IsFriday()
{
if (table.Columns.Count == 16)
return true;
return false;
}
public List<Broadcast> GetBroadcastsFriday()
{
var broadcasts = new List<Broadcast>();
for (var i = 0; i < table.Rows.Count; i++)
{
if (table.Rows[i][0].ToString().Length > 1)
{
broadcasts.Add(new Broadcast
{
Time = new Time(table.Rows[i][0].ToString()),
Title = table.Rows[i][1].ToString(),
File = table.Rows[i][3].ToString(),
Type = table.Rows[i][7].ToString(),
Id = table.Rows[i][2].ToString(),
Length = new Time(table.Rows[i][4].ToString())
});
}
}
return broadcasts;
}
public List<Broadcast> GetBroadcastsTvc()
{
var broadcasts = new List<Broadcast>();
for (var i = 0; i < table.Rows.Count; i++)
{
broadcasts.Add(new Broadcast
{
Time = new Time(table.Rows[i][0].ToString()),
Title = table.Rows[i][2].ToString().Trim(),
File = table.Rows[i][6].ToString().Trim(),
Type = table.Rows[i][9].ToString().Trim(),
Id = table.Rows[i][1].ToString().Trim(),
Length = new Time(table.Rows[i][5].ToString())
});
}
return broadcasts;
}
public void Dispose()
{
}
}
}
Her 08.12.2015 20:10 # +1
bormand 08.12.2015 20:11 # +4
3_14dar 09.12.2015 13:45 # 0
Vindicar 11.12.2015 10:26 # 0
Чё значит нет, а если найду?