public void ReadCompliedTsvWithClass() { var tabFile = TableFile <TestExcelInfo> .LoadFromFile("./test_excel.bytes"); var config = tabFile.FindByPrimaryKey(1); Assert.IsNotNull(config); Assert.AreEqual(config.Name, "Test1"); }
public void CommandLine1() { CommandProgram.Run(new string[] { "-Folder", "./*.xls" }); Assert.IsTrue(File.Exists("TabConfigs.cs")); var table = TableFile.LoadFromFile("./test_excel.bytes"); ReadCompliedTsv(); }
public void ReadCompliedTsv() { var tabFile = TableFile.LoadFromFile("./test_excel.bytes"); Assert.AreEqual <int>(3, tabFile.GetColumnCount()); var headerNames = tabFile.HeaderNames.ToArray(); Assert.AreEqual("Id", headerNames[0]); Assert.AreEqual("Name", headerNames[1]); Assert.AreEqual("StrArray", headerNames[2]); }
public void TestRemoveRowTableFile1() { var tabFileWrite = new TabFileWriter <TestWrite>(); var newRow = tabFileWrite.NewRow(); newRow.TestColumn1 = "Test String"; newRow.TestColumn2 = 123123; tabFileWrite.RemoveRow(newRow.RowNumber); // remove row 1 tabFileWrite.Save("./test_write.bytes"); var tabFileRead = TableFile <TestWrite> .LoadFromFile("./test_write.bytes"); Assert.AreEqual(tabFileRead.GetHeight(), 0); }
public void TestWriteTableFile2() { var tabFile = TableFile <TestWrite> .LoadFromFile("./test_write.bytes"); var tabFileWrite = new TabFileWriter <TestWrite>(tabFile); var newRow = tabFileWrite.NewRow(); newRow.TestColumn1 = Path.GetRandomFileName(); newRow.TestColumn2 = new Random().Next(); // 两个方法执行后 Assert.AreEqual(tabFile.GetHeight(), 2); tabFileWrite.Save("./test_write.bytes"); }
private void ParseTsv(string filePath) { _tableFile = TableFile.LoadFromFile(filePath, Encoding.GetEncoding("GBK")); _columnCount = _tableFile.GetColumnCount(); // 通过TableFile注册头信息 var commentRow = _tableFile.GetRow(1); foreach (var kv in _tableFile.Headers) { var header = kv.Value; ColName2Index[header.HeaderName] = header.ColumnIndex; Index2ColName[header.ColumnIndex] = header.HeaderName; ColName2Statement[header.HeaderName] = header.HeaderMeta; ColName2Comment[header.HeaderName] = commentRow[header.ColumnIndex]; } }