public void WriteToExcel_IntegerArray_Test() { var writtenInput = new List <int> { 2, 3, 4, 5 }; _excelWriter.WriteToExcel <int>(writtenInput, 1); var readOutput = ExcelReader.ReadSheet(1, maintainOrder: true). Select(int.Parse).ToList(); CollectionAssert.AreEqual(writtenInput, readOutput); }
/// <summary> /// Load data from SharpCloud and save it to an Excel file. Only needed when /// SharpCloud is a data source, so the upload process can work on local data. /// </summary> public async Task InitialiseDatabase( SharpCloudConfiguration config, string connectionString, DatabaseType dbType) { if (dbType == DatabaseType.SharpCloudExcel) { var filename = _connectionStringHelper.GetVariable(connectionString, DatabaseStrings.DataSourceKey); var sourceId = _connectionStringHelper.GetVariable(connectionString, "SourceId"); var csUsername = _connectionStringHelper.GetVariable(connectionString, "SourceUserName"); var csPassword = _connectionStringHelper.GetVariable(connectionString, "SourcePassword"); var csServer = _connectionStringHelper.GetVariable(connectionString, "SourceServer"); var username = string.IsNullOrWhiteSpace(csUsername) ? config.Username : csUsername; var password = string.IsNullOrWhiteSpace(csPassword) ? config.Password : Encoding.Default.GetString(Convert.FromBase64String(csPassword)); var server = string.IsNullOrWhiteSpace(csServer) ? config.Url : csServer; await _logger.Log("Initialising data source..."); var sc = _sharpCloudApiFactory.CreateSharpCloudApi( username, password, server, config.ProxyUrl, config.UseDefaultProxyCredentials, config.ProxyUserName, config.ProxyPassword); if (sc == null) { throw new InvalidCredentialsException(); } var story = sc.LoadStory(sourceId); var items = story.GetItemsData(); var relationships = story.GetRelationshipsData(); await _logger.Log($"Writing story to {filename}"); _excelWriter.WriteToExcel(filename, items, relationships); await _logger.Log("Data source ready"); } }
public void writeToExcel() { logger.Info("Excel Hander - Write to Excel: Started"); try { excelWriter.WriteToExcel(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } }
public void writeToExcel(DataTable dt, DateTime dateFrom, DateTime dateTo) { logger.Info("Excel Hander - Write to Excel: Started"); try { excelWriter.WriteToExcel(dt, dateFrom, dateTo); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } }
public async Task <Byte[]> DownloadStudyDataAsync() { var data = _userService.GetUserQueryable(); return(await _excelWriter.WriteToExcel <LVIStudyUser>(data)); }