public void Load(IWorkbook workbook, Stream stream, Encoding encoding, object arg, string singleSheet = "") { bool autoSpread = true; int bufferLines = CSVFormat.DEFAULT_READ_BUFFER_LINES; RangePosition targetRange = RangePosition.EntireRange; CSVFormatArgument csvArg = arg as CSVFormatArgument; if (csvArg != null) { autoSpread = csvArg.AutoSpread; bufferLines = csvArg.BufferLines; targetRange = csvArg.TargetRange; } Worksheet sheet = null; if (workbook.Worksheets.Count == 0) { sheet = workbook.CreateWorksheet("Sheet1"); workbook.Worksheets.Add(sheet); } else { while (workbook.Worksheets.Count > 1) { workbook.Worksheets.RemoveAt(workbook.Worksheets.Count - 1); } sheet = workbook.Worksheets[0]; sheet.Reset(); } CSVFormat.Read(stream, sheet, targetRange, encoding, bufferLines, autoSpread); }
public object Load(IWorkbook workbook, Stream stream, Encoding encoding, object arg) { CSVFormatArgument csvArg = arg as CSVFormatArgument; if (csvArg == null) { csvArg = new CSVFormatArgument(); } Worksheet sheet = null; if (workbook.Worksheets.Count == 0) { sheet = workbook.CreateWorksheet("Sheet1"); workbook.Worksheets.Add(sheet); } else { while (workbook.Worksheets.Count > 1) { workbook.Worksheets.RemoveAt(workbook.Worksheets.Count - 1); } sheet = workbook.Worksheets[0]; sheet.Reset(); } CSVFormat.Read(stream, sheet, encoding, csvArg); return(csvArg); }
/// <summary> /// Load workbook from specified input stream /// </summary> /// <param name="workbook">Workbook to be loaded</param> /// <param name="stream">Input stream</param> /// <param name="encoding">Encoding used to read text-based stream, such as XML</param> /// <param name="arg">Provider custom parameters</param> public void Load(IWorkbook workbook, Stream stream, Encoding encoding, object arg) { Worksheet sheet = null; if (workbook.Worksheets.Count == 0) { sheet = workbook.CreateWorksheet("Sheet1"); workbook.Worksheets.Add(sheet); } else { sheet = workbook.Worksheets[0]; } sheet.LoadRGF(stream); }
public void Load(IWorkbook workbook, List <T> obj, object arg) { bool autoSpread = true; string sheetName = String.Empty; int bufferItems = DEFAULT_READ_BUFFER_ITEMS > obj.Count ? obj.Count : DEFAULT_READ_BUFFER_ITEMS; RangePosition targetRange = RangePosition.EntireRange; GenericFormatArgument genericArg = arg as GenericFormatArgument; if (genericArg != null) { sheetName = genericArg.SheetName; targetRange = genericArg.TargetRange; } Worksheet sheet = null; if (workbook.Worksheets.Count == 0) { sheet = workbook.CreateWorksheet(sheetName); workbook.Worksheets.Add(sheet); } else { while (workbook.Worksheets.Count > 1) { workbook.Worksheets.RemoveAt(workbook.Worksheets.Count - 1); } sheet = workbook.Worksheets[0]; sheet.Reset(); } this.Read(obj, sheet, targetRange, bufferItems, autoSpread); // ApplyStyles(sheet, genericArg.Stylesheet); }
public RSWorkbook(IWorkbook workbook) { this.workbook = workbook; this["worksheets"] = new ExternalProperty(() => { if (worksheetCollection == null) { worksheetCollection = new RSWorksheetCollection(workbook); } return(worksheetCollection); }); this["currentWorksheet"] = new ExternalProperty(() => { if (ControlInstance != null) { var rsWorksheet = ControlInstance.CurrentWorksheet.worksheetObj; if (rsWorksheet == null) { rsWorksheet = new RSWorksheet(ControlInstance.CurrentWorksheet); ControlInstance.CurrentWorksheet.worksheetObj = rsWorksheet; } return(rsWorksheet); } else { return(null); } }); this["createWorksheet"] = new NativeFunctionObject("createWorksheet", (ctx, owner, args) => { return(new RSWorksheet(workbook.CreateWorksheet(args.Length > 0 ? ScriptRunningMachine.ConvertToString(args[0]) : null))); }); this["addWorksheet"] = new NativeFunctionObject("createWorksheet", (ctx, owner, args) => { if (args.Length < 1) { return(null); } workbook.AddWorksheet(RSWorksheet.Unbox(args[0])); return(null); }); this["insertWorksheet"] = new NativeFunctionObject("createWorksheet", (ctx, owner, args) => { if (args.Length < 2) { return(null); } workbook.InsertWorksheet(ScriptRunningMachine.GetIntValue(args[0]), RSWorksheet.Unbox(args[1])); return(null); }); this["removeWorksheet"] = new NativeFunctionObject("createWorksheet", (ctx, owner, args) => { if (args.Length < 1) { return(null); } Worksheet sheet = RSWorksheet.Unbox(args[0]); if (sheet != null) { return(workbook.RemoveWorksheet(sheet)); } else { return(workbook.RemoveWorksheet(ScriptRunningMachine.GetIntValue(args[0]))); } }); }
public void AddSheet(string sheetName = "") { worksheet = workbook.CreateWorksheet(sheetName); }