protected override void AddParsedExternName(string ExternSheet, string ExternName) { bool IsLocal; int Sheet; int extsheet = Xls.GetExternSheet(ExternSheet, false, ReadingXlsx, out IsLocal, out Sheet); int extname = -1; if (IsLocal) { extname = GetNamedRangeIndex(ExternName, Sheet + 1, true); if (ReadingXlsx && extname < 0) { extname = Xls.AddEmptyName(ExternName, Sheet + 1); } } else { extname = Xls.EnsureExternName(extsheet, ExternName); } if (extname < 0) { FlxMessages.ThrowException(FlxErr.ErrInvalidRef, ExternSheet + fts(TFormulaToken.fmExternalRef) + ExternName); } AddParsedExternName(extsheet, extname); }
public static IFormat getType(string type_) { IFormat type = null; try { switch (type_.ToLower()) { case "csv": type = new CSV(); break; case "xls": type = new Xls(); break; case "xlsx": type = new Xlsx(); break; // Expand list here } } catch (Exception) { throw new Exception("Incorrect file type"); } return(type); }
public virtual Xls XlsEkle(byte[] xlsBinary, string mimeTipi, string seoDosyaAdı, string altÖznitelik = null, string başlıkÖznitelik = null, bool Yeni = true, bool BinaryDoğrula = true) { mimeTipi = GenelYardımcı.BoşKontrol(mimeTipi); mimeTipi = GenelYardımcı.MaksimumUzunlukKontrol(mimeTipi, 20); seoDosyaAdı = GenelYardımcı.MaksimumUzunlukKontrol(seoDosyaAdı, 100); /* * if (BinaryDoğrula) * xlsBinary = ResimDoğrula(resimBinary, mimeTipi); */ var xls = new Xls { XlsBinary = new byte[0], MimeTipi = mimeTipi, SeoDosyaAdı = seoDosyaAdı, AltÖznitelik = altÖznitelik, BaşlıkÖznitelik = başlıkÖznitelik, Yeni = Yeni, }; DosyayaXlsKaydet(xls.Id, xlsBinary, mimeTipi); return(xls); }
public virtual byte[] XlsBinaryYükle(Xls xls) { if (xls == null) { throw new ArgumentNullException("xls"); } var sonuç = DosyadanXlsYükle(xls.Id, xls.MimeTipi); return(sonuç); }
protected override void AddParsed3dRef(string ExternSheet, int Row, int Col, bool RowAbs, bool ColAbs) { if (RelativeAddress) { Push(new TRef3dNToken(GetRealPtg(ptg.Ref3d, TFmReturnType.Ref), Xls.GetExternSheet(ExternSheet, ReadingXlsx), Row - RelStartRow(RowAbs), Col - RelStartCol(ColAbs), RowAbs, ColAbs, false)); } else { Push(new TRef3dToken(GetRealPtg(ptg.Ref3d, TFmReturnType.Ref), Xls.GetExternSheet(ExternSheet, ReadingXlsx), Row, Col, RowAbs, ColAbs)); } }
public virtual string XlsUrlAl(Xls xls, int hedefBüyüklüğü = 0, bool varsayılanResimGöster = true, string kaynakKonumu = null) { string url = string.Empty; byte[] xlsBinary = null; if (xls != null) { xlsBinary = XlsBinaryYükle(xls); } if (xls == null || xlsBinary == null || xlsBinary.Length == 0) { if (varsayılanResimGöster) { url = XlsVarsayılanUrlAl(hedefBüyüklüğü, kaynakKonumu); } return(url); } /* * if (xls.Yeni) * { * xls = ResimGüncelle(xls.Id, * xlsBinary, * xls.MimeTipi, * xls.SeoDosyaAdı, * xls.AltÖznitelik, * xls.BaşlıkÖznitelik, * false, * false); * } */ var seoFileName = xls.SeoDosyaAdı; string sonParça = MimeTipindenDosyaUzantısınıAl(xls.MimeTipi); string thumbDosyaAdı; if (hedefBüyüklüğü == 0) { thumbDosyaAdı = !String.IsNullOrEmpty(seoFileName) ? string.Format("{0}_{1}.{2}", xls.Id.ToString("0000000"), seoFileName, sonParça) : string.Format("{0}.{1}", xls.Id.ToString("0000000"), sonParça); } else { thumbDosyaAdı = !String.IsNullOrEmpty(seoFileName) ? string.Format("{0}_{1}_{2}.{3}", xls.Id.ToString("0000000"), seoFileName, hedefBüyüklüğü, sonParça) : string.Format("{0}_{1}.{2}", xls.Id.ToString("0000000"), hedefBüyüklüğü, sonParça); } return(url); }
protected override void AddParsed3dArea(string ExternSheet, int Row1, int Row2, int Col1, int Col2, bool RowAbs1, bool RowAbs2, bool ColAbs1, bool ColAbs2) { if (RelativeAddress) { //Really we should get an offset here, but as there is no active cell, we will assume the cell where the cursor is on is A1. So Row and Col are the offsets. Push(new TArea3dNToken(GetRealPtg(ptg.Area3d, TFmReturnType.Ref), Xls.GetExternSheet(ExternSheet, ReadingXlsx), Row1 - RelStartRow(RowAbs1), Col1 - RelStartCol(ColAbs1), RowAbs1, ColAbs1, Row2 - RelStartRow(RowAbs1), Col2 - RelStartCol(ColAbs2), RowAbs2, ColAbs2, false)); } else { Push(new TArea3dToken(GetRealPtg(ptg.Area3d, TFmReturnType.Ref), Xls.GetExternSheet(ExternSheet, ReadingXlsx), Row1, Col1, RowAbs1, ColAbs1, Row2, Col2, RowAbs2, ColAbs2)); } }
protected virtual void DosyaSistemindenResimSil(Xls xls) { if (xls == null) { throw new ArgumentNullException("xls"); } string sonParça = MimeTipindenDosyaUzantısınıAl(xls.MimeTipi); string dosyaAdı = string.Format("{0}_0.{1}", xls.Id.ToString("0000000"), sonParça); string dosyaYolu = XlsLocalYolunuAl(dosyaAdı); if (File.Exists(dosyaYolu)) { File.Delete(dosyaYolu); } }
// UnitData row from index public UnitDataRow GetUnitDataRowFromIndex(Xls.TableCodes tableCode, Int32 index) { return (UnitDataRow)GetRowFromIndex(tableCode, index); }
// UnitData row from code public UnitDataRow GetUnitDataRowFromCode(Xls.TableCodes tableCode, Int16 code) { return (UnitDataRow)GetRowFromCode(tableCode, code); }
// not needed anymore (name is obtained automatically) //private void GenerateUnitNameStrings(UnitObject[] units, Hashtable hash) //{ // if (hash == null) hash = new Hashtable(); // try // { // UnitObjectStats.Stat stat; // foreach (UnitObject unit in units) // { // for (int counter = 0; counter < unit.Stats.Stats.Count; counter++) // { // stat = unit.Stats.Stats[counter]; // String name; // if (hash.Contains(stat.Code)) // { // name = (string)hash[stat.Code]; // } // else // { // DataRow[] statRows = statsTable.Select("code = " + stat.Code); // name = (string)statRows[0]["stat"]; // if (name != null) // { // hash.Add(stat.Code, name); // } // } // unit.Stats[counter].Name = name; // } // GenerateUnitNameStrings(unit.Items.ToArray(), hash); // } // } // catch (Exception ex) // { // MessageBox.Show(ex.Message, "GenerateUnitNameStrings"); // } //} public string MapIdToString(UnitObjectStats.Stat stat, Xls.TableCodes tableId, int lookupId) { string value = string.Empty; if (stat.Values.Count != 0) { String select = String.Format("code = '{0}'", lookupId); DataTable table = null;// todo: rewrite _dataSet.GetExcelTableFromCode((uint)tableId); DataRow[] row; if (table != null) { row = table.Select(select); if (row != null && row.Length != 0) { value = (string)row[0][1]; } } } return value; }
public int GetCodeFromRow(Xls.TableCodes tableCode, object row) { ExcelFile table = GetExcelTableFromCode(tableCode); int code; return (table.CodeFromRow.TryGetValue(row, out code)) ? code : -1; }
public Object GetRowFromValue(Xls.TableCodes tableCode, String colName, Object value) { if (value == null || String.IsNullOrEmpty(colName)) return null; ExcelFile excelTable = GetExcelTableFromCode(tableCode); if (excelTable == null) return null; ObjectDelegator tableDelegate = DataFileDelegators[excelTable.StringId]; ObjectDelegator.FieldDelegate fieldDelegate = tableDelegate.GetFieldDelegate(colName); if (fieldDelegate == null) return null; foreach (Object row in excelTable.Rows) { if (value.Equals(fieldDelegate.GetValue(row))) return row; } return null; }
// Row from index public object GetRowFromIndex(Xls.TableCodes tableCode, Int32 index) { ExcelFile table = GetExcelTableFromCode(tableCode); return index < table.Rows.Count() ? (table.Rows[index]) : null; }
// Row from first string public object GetRowFromFirstString(Xls.TableCodes tableCode, String firstString) { ExcelFile table = GetExcelTableFromCode(tableCode); Object row; return (table.RowFromFirstString.TryGetValue(firstString, out row)) ? row : null; }
// Row from code public object GetRowFromCode(Xls.TableCodes tableCode, Int16 code) { ExcelFile table = GetExcelTableFromCode(tableCode); object row; return (table.RowFromCode.TryGetValue(code, out row)) ? row : null; }
/// <summary> /// Retrieves an Excel Table from its Code value. If it's not loaded, then it will be loaded and returned. /// </summary> /// <param name="code">The code of the Excel Table to retrieve.</param> /// <returns>The Excel Table as a DataTable, or null if not found.</returns> public ExcelFile GetExcelTableFromCode(Xls.TableCodes code) { if (DataFiles == null || DataFiles.ContainsKey(ExcelTablesStringId) == false || code == Xls.TableCodes.Null) return null; if (_excelCodeToTable == null) { ExcelFile excelTables = (ExcelFile)DataFiles[ExcelTablesStringId]; _excelCodeToTable = new Dictionary<Xls.TableCodes, ExcelFile>(); foreach (ExcelTablesRow excelTablesRow in excelTables.Rows) { DataFile dataFile; if (DataFiles.TryGetValue(excelTablesRow.name, out dataFile)) { _excelCodeToTable[(Xls.TableCodes)excelTablesRow.code] = (ExcelFile)dataFile; } } } ExcelFile excelTable; return _excelCodeToTable.TryGetValue(code, out excelTable) ? excelTable : null; }
public String GetExcelStringFromRowIndex(Xls.TableCodes code, int rowIndex, int colIndex = 0) { if (DataFiles == null || DataFiles.ContainsKey(ExcelTablesStringId) == false || rowIndex < 0) return null; ExcelFile excelTable = GetExcelTableFromCode(code); String stringVal = _GetExcelStringFromExcelFile(excelTable, rowIndex, colIndex); return stringVal; }
// Row index from code public int GetRowIndexFromCode(Xls.TableCodes tableCode, Int16 code) { ExcelFile table = GetExcelTableFromCode(tableCode); Object row; return (table.RowFromCode.TryGetValue(code, out row)) ? table.IndexFromRow[row] : -1; }
// code from first string public int GetCodeFromFirstString(Xls.TableCodes tableCode, String firstString) { ExcelFile table = GetExcelTableFromCode(tableCode); object row; if (table.RowFromFirstString.TryGetValue(firstString, out row)) { int code; return (table.CodeFromRow.TryGetValue(row, out code)) ? code : -1; } return -1; }
protected override void AddParsed3dRefErr(string ExternSheet) { Push(new TRef3dToken(GetRealPtg(ptg.Ref3dErr, TFmReturnType.Ref), Xls.GetExternSheet(ExternSheet, ReadingXlsx), 0, 0, false, false)); }
// Row index from first string public int GetRowIndexFromFirstString(Xls.TableCodes tableCode, String firstString) { ExcelFile table = GetExcelTableFromCode(tableCode); object row = GetRowFromFirstString(tableCode, firstString); if (row != null) { int index = 0; return (table.IndexFromRow.TryGetValue(row, out index)) ? index : -1; } return -1; }
public int GetRowIndexFromRow(Xls.TableCodes tableCode, object row) { ExcelFile table = GetExcelTableFromCode(tableCode); if (row != null) { int index; return (table.IndexFromRow.TryGetValue(row, out index)) ? index : -1; } return -1; }
private static void _WriteStatParamData(BitBuffer bitBuffer, int bitCount, int paramShift, bool paramIsOffset, Xls.TableCodes tableCode) { if (bitCount <= 0) { bitBuffer.WriteBool(false); return; } bitBuffer.WriteBool(true); bitBuffer.WriteBits(bitCount, 6); int paramOperationsFlags = 0; if (paramShift > 0) paramOperationsFlags |= 0x01; if (paramIsOffset) paramOperationsFlags |= 0x02; bitBuffer.WriteBits(paramOperationsFlags, 2); if ((paramOperationsFlags & 0x01) != 0) { bitBuffer.WriteBits(paramShift, 3); } if ((paramOperationsFlags & 0x02) != 0) { bitBuffer.WriteBool(paramIsOffset); } bool hasTableCode = (tableCode != Xls.TableCodes.Null && tableCode != Xls.TableCodes.None); bitBuffer.WriteBool(!hasTableCode); if (hasTableCode) { bitBuffer.WriteUInt16((uint)tableCode); } }