private static bool ValidateExtension(HttpPostedFileBase file) { ReadExcelData validateEXT = new ReadExcelData(); bool extValidate = validateEXT.ValidateFileExtension(file); return(extValidate); }
public ActionResult Index(HttpPostedFileBase file, FormCollection formCollection, string submitButton) { if (submitButton != null) { submitButton = submitButton.ToLower().Trim(); } string pageSizeDDL = string.Empty; if (file == null && formCollection.Count == 0 && submitButton == null) { InvalidFileSelected(); } else if (file != null) { if (Request.Files["file"].ContentLength > 0) { ReadExcelData validateEXT = new ReadExcelData(); bool extValidate = validateEXT.ValidateFileExtension(file); if (!extValidate) { InvalidFileSelected(); } else { string fileLocation = FileLocationPath(); Session.Add("fileLocation", fileLocation); if (!CheckAnyErrorReadingFile()) { //extract from excel file.... ReadExcelData loadExcelData = new ReadExcelData(); List <ExcelViewModel> loadedData = loadExcelData.LoadDataFromExcel(fileLocation); if (loadedData.Count() > 0) { if (!CheckForInvalidDataInExcel()) { ValidateExcelData validateExcelData = new ValidateExcelData(); validateExcelData.RunValidationCheck(loadedData); } } } } } } else if (submitButton != null) { SubmitButton(formCollection, submitButton); } return(View(SessionWrapper.GetSession_Model())); }
private void btnMySqlInDB_Click(object sender, EventArgs e) { action(new Action(() => { var temps = (this.lbFiles.Tag as List <ItemFileInfo>); List <string> files = temps.Where((l) => l.ExtensionName.Equals(".xls")).Select(l => l.Path).ToList(); FileExcelDatas exceldatas; if (ReadExcelData.Instance().ReadExcelDataToCache(files, out exceldatas, new Action <string>((msg) => { Show(msg); }), true)) { CreateMysql.Instance().ActionExcel(exceldatas, "AS", this.tbdbpack.Text, true, new Action <string>((msg) => { Show(msg); })); Show(""); Show("Excel 转 Mysql 并且插入数据库 全部处理完成 "); } })); }
private void btntxt_Click(object sender, EventArgs e) { action(new Action(() => { var temps = (this.lbFiles.Tag as List <ItemFileInfo>); List <string> files = temps.Where((l) => l.ExtensionName.Equals(".xls")).Select(l => l.Path).ToList(); FileExcelDatas exceldatas; if (ReadExcelData.Instance().ReadExcelDataToCache(files, out exceldatas, new Action <string>((msg) => { Show(msg); }))) { CreateText.Instance().ActionExcelData(exceldatas, "|", new Action <string>((msg) => { Show(msg); })); Show("Excel 转 Text 全部处理完成 文件目录:" + CreateBase.TextPath); try { System.Diagnostics.Process.Start(CreateBase.TextPath); } catch { } } })); }
private void btnCodeFirst_Click(object sender, EventArgs e) { action(new Action(() => { var temps = (this.lbFiles.Tag as List <ItemFileInfo>); List <string> files = temps.Where((l) => l.ExtensionName.Equals(".xls")).Select(l => l.Path).ToList(); FileExcelDatas exceldatas; if (ReadExcelData.Instance().ReadExcelDataToCache(files, out exceldatas, new Action <string>((msg) => { Show(msg); }), true)) { CreateCodeFirstCSharp.Instance().ActionExcelData(exceldatas, this.tbcodepack.Text, new Action <string>((msg) => { Show(msg); })); Show(""); Show("Excel 转 服务器 CSharp Code First 类 全部处理完成 文件目录:" + CreateBase.JavaJpaCodePathData); try { System.Diagnostics.Process.Start(CreateBase.JavaJpaCodePathData); } catch { } } })); }
private void btnClientXml_Click(object sender, EventArgs e) { action(new Action(() => { var temps = (this.lbFiles.Tag as List <ItemFileInfo>); List <string> files = temps.Where((l) => l.ExtensionName.Equals(".xls")).Select(l => l.Path).ToList(); FileExcelDatas exceldatas; if (ReadExcelData.Instance().ReadExcelDataToCache(files, out exceldatas, new Action <string>((msg) => { Show(msg); }), false)) { //生成XML CreateXml.Instance().ActionExcelData(exceldatas, "AC", this.cb_isnull.Checked, new Action <string>((msg) => { Show(msg); })); //生成 Xml 对应 CSharp CreateXMLCSharp.Instance().ActionExcelData(exceldatas, this.tbcodepack.Text, new Action <string>((msg) => { Show(msg); })); Show("Excel 转 客户端专属 XML 文件处理完成"); try { System.Diagnostics.Process.Start(CreateBase.CSharpPath); } catch { } } })); }
public CompanyDataViewModel() { readExcelData = new ReadExcelData(); Companies = readExcelData.GetAllCompanies(); }
private void ReadExcelFile(string filePath) { var readExcelData = new ReadExcelData(); readExcelData.ReadExcel(filePath, CompanyName); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var readExcelData = new ReadExcelData(); var sheets = readExcelData.ReadExcel(@"C:\Program Files (x86)\EuromonitorInternational\CompanyAnnualReport\ReportsRepository\0000320187_10-K.xlsx", "Nike"); }