1。首先写一个Excel表格,第一行数据库类型(varchar、date、decimal)。第二行数据库类型长度(100、12,4、时间日期为空)
2。html 加按钮
{
type: "button",
text: "报价信息导入",
click: function () {
GA.clearScreenMessage();
//terpQuoteMnt=>表名, GA.currentUser.CompanyId=>公司id ,uploadPopupQuoteDiv =>div
var data = ["terpQuoteMnt", GA.currentUser.CompanyId, "uploadPopupQuoteDiv"];
GA.current.window = $("#uploadPopupQuoteDiv").kendoWindow({
// modal: true,
content: { url: "/Common/BaseDataUploadQuery", data: { name: JSON.stringify(data) }},
iframe: false,
width: 900,
height: 200,
title: "报价信息文件上传",
}).data("kendoWindow");
GA.current.window.center().open();
}
},
3。(下载模板)设置Excel中模板下拉框,为可新增下拉框或不可新增下拉框,实现对用户的一些输入限制
using DC.BE.Business.ERP;
using DC.BE.Business.ERP.ProductsMange;
using DC.BE.Business.SYS;
using DC.BE.Entity.Security;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
//using DC.BE.Entity.SYS;
using System.Data.Entity;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using DC.BE.Business.ERP.Purchases; ///Install-Package NPOI
namespace DC.Website.MVC5.Controllers.SYS.Base
{
public class BaseDataExportController : Controller
{
#region
private readonly ITsysCompCodeBusiness _tsysCompCodeBusiness;
private readonly IterpProductBusiness _terpProductBusiness;
private readonly IterpPersonInfoBusiness _terpPersonInfoBusiness;
private readonly IterpPartBusiness _terpPartBusiness;
private readonly ITsysManagementBusiness _tsysManagementBusiness;
private readonly DcContext _dcContext;
private readonly ItsysCompRoleBusiness _tsysCompRoleBusiness;
private readonly ITsysUserBusiness _tsysUserBusiness;
private readonly ITerpQuotedPriceTemplateBusiness _terpQuotedPriceTemplateBusiness;
public BaseDataExportController(ITsysCompCodeBusiness tsysCompCodeBusiness, IterpProductBusiness terpProductBusiness,
IterpPersonInfoBusiness terpPersonInfoBusiness, IterpPartBusiness terpPartBusiness, ITsysManagementBusiness tsysManagementBusiness,
ITerpQuotedPriceTemplateBusiness terpQuotedPriceTemplateBusiness,
DcContext dcContext, ItsysCompRoleBusiness tsysCompRoleBusiness,ITsysUserBusiness tsysUserBusiness)
{
_tsysCompCodeBusiness = tsysCompCodeBusiness;
_terpProductBusiness = terpProductBusiness;
_terpPersonInfoBusiness = terpPersonInfoBusiness;
_terpPartBusiness = terpPartBusiness;
_tsysManagementBusiness = tsysManagementBusiness;
_dcContext = dcContext;
_tsysCompRoleBusiness = tsysCompRoleBusiness;
_tsysUserBusiness = tsysUserBusiness;
_terpQuotedPriceTemplateBusiness = terpQuotedPriceTemplateBusiness;
}
#endregion private const string TemplatePath = @"~\Template\Excel\";
private const int MaxRowIndex = ;
//[AllowAnonymous]
public ActionResult ExportTemplate(string template)
{
switch (template)
{
case "terpPersonInfo":
return ExportTerpPersonInfo();
case "terpPartInfo":
return ExportTerpPartInfo();
case "terpProductInfo":
return ExportTerpProductBase();
case "terpMaterialBase":
return ExportTerpMaterialBase();
case "tsysCompOrg":
return ExportTsysCompOrg();
case "tsysCompRole":
return ExportTsysCompRole();
case "tsysUser":
return ExportTsysUser();
case "tsysUserRole":
return ExportTsysUserRole();
case "TerpWorkHourCostTypeId":
return ExportTerpWorkHourCostTypeId();
case "terpSupplierInfo":
return ExportTerpSupplierInfo();
case "terpSupplyBase":
return ExportTerpSupplyBase();
case "tsysStoreInfo":
return ExportTsysStoreInfo();
case "terpTechUseMaterialDF":
return ExportTerpTechUseMaterialDF();
case "terpProductDesignBom":
return ExportTerpDesignBom();
case "terpPartRelation":
return ExportTerpDesignBomPartRelation();
case "terpPartTotolStoreInfo":
return ExportTerpPartTotolStoreInfo();
case "tsysStorePartition":
return ExportTsysStorePartition();
case "tsysStoreLocation":
return ExportTsysStoreLocation();
case "tcrmCustomerInfo":
return ExportTcrmCustomerInfo();
case "terpPartInStoreInfo":
return ExportTerpPartInStoreInfo();
case "tsasAgentRegister":
return ExportTsasAgentRegister();
case "tsasRegCompServiceNote":
return ExportTsasRegCompServiceNote();
case "terpQuoteMnt":
return ExportTerpQuoteMnt();
default:
return ExportTerpPersonInfo();
} } #region 由数据源生成下拉菜单
/// <summary>
/// 由数据源生成下拉菜单
/// </summary>
/// <param name="workbook">XSSFWorkbook</param>
/// <param name="category">category</param>
/// <param name="columnName">列标题</param>
/// <param name="colString">下拉菜单列坐标</param>
/// <param name="sheetIndex">下拉菜单sheet页索引</param>
/// <param name="firstRowIndex">下拉菜单起始行索引</param>
/// <param name="lastRowIndex">下拉菜单结束行索引</param>
private void GenerateDropdownListRow(XSSFWorkbook workbook, string category, string columnName, string colString,
int sheetIndex = , int firstRowIndex = , int lastRowIndex = MaxRowIndex)
{
var sheet = workbook.GetSheetAt(sheetIndex);
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)sheet);
//下拉菜单数据源
string[] data = _tsysCompCodeBusiness.GetCodesByCategoryCodeCompanyId(category).Select(x => x.Item_Name).OrderBy(x => x).ToArray(); if (data.Length == )
{
data = new string[] { "" };
} int validationLength = string.Join(",", data).Length;
/*
There are limits to the number of items that will show in a data validation drop down list:
The list can show up to show 32,767 items from a list on the worksheet.
If you type the items into the data validation dialog box (a delimited list), the limit is 256 characters, including the separators.
*/
if (validationLength >= || data.Length > )
{
ISheet hidden = null;
if (workbook.GetSheet("hidden") == null)
{
hidden = workbook.CreateSheet("hidden");
}
int hiddenSheetIndex = workbook.GetSheetIndex(workbook.GetSheet("hidden"));
GenerateCascadingDropdownListRow(workbook, data, columnName, colString, colString, ddlSheetIndex: sheetIndex, dsSheetIndex: hiddenSheetIndex);
workbook.SetSheetHidden(hiddenSheetIndex, true);
return;
} XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint)
dvHelper.CreateExplicitListConstraint(data);
//根据列坐标获取索引
int colIndex = CellReference.ConvertColStringToIndex((colString ?? "").ToUpper());
//下拉菜单约束范围
CellRangeAddressList addressList = new CellRangeAddressList(firstRowIndex, lastRowIndex, colIndex, colIndex);
XSSFDataValidation validation = (XSSFDataValidation)dvHelper.CreateValidation(dvConstraint, addressList);
validation.ShowErrorBox = true;
//string colName = sheet.GetRow(firstRowIndex - 1).GetCell(colIndex).StringCellValue;
validation.CreateErrorBox("错误", columnName + "错误");//不符合约束时提示
sheet.AddValidationData(validation);
} private void GenerateDropdownListRow(XSSFWorkbook workbook, string[] data, string columnName, string colString,
int sheetIndex = , int firstRowIndex = , int lastRowIndex = MaxRowIndex)
{
var sheet = workbook.GetSheetAt(sheetIndex);
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)sheet);
//下拉菜单数据源
//string[] data = _tsysCompCodeBusiness.GetCodesByCategoryCode(category).Select(x => x.Item_Name).ToArray();
if (data.Length == )
{
data = new string[] { "" };
} int validationLength = string.Join(",", data).Length;
/*
There are limits to the number of items that will show in a data validation drop down list:
The list can show up to show 32,767 items from a list on the worksheet.
If you type the items into the data validation dialog box (a delimited list), the limit is 256 characters, including the separators.
*/
if (validationLength >= || data.Length > )
{
ISheet hidden = null;
if (workbook.GetSheet("hidden") == null)
{
hidden = workbook.CreateSheet("hidden");
}
int hiddenSheetIndex = workbook.GetSheetIndex(workbook.GetSheet("hidden"));
GenerateCascadingDropdownListRow(workbook, data, columnName, colString, colString, ddlSheetIndex: sheetIndex, dsSheetIndex: hiddenSheetIndex);
workbook.SetSheetHidden(hiddenSheetIndex, true);
return;
} XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint)
dvHelper.CreateExplicitListConstraint(data);
//根据列坐标获取索引
int colIndex = CellReference.ConvertColStringToIndex((colString ?? "").ToUpper());
//下拉菜单约束范围
CellRangeAddressList addressList = new CellRangeAddressList(firstRowIndex, lastRowIndex, colIndex, colIndex);
XSSFDataValidation validation = (XSSFDataValidation)dvHelper.CreateValidation(dvConstraint, addressList);
validation.ShowErrorBox = true;
//string colName = sheet.GetRow(firstRowIndex - 1).GetCell(colIndex).StringCellValue;
validation.CreateErrorBox("错误", columnName + "错误");//不符合约束时提示
sheet.AddValidationData(validation);
}
#endregion #region 数据有效性验证 列元素不可重复
/// <summary>
/// 数据有效性验证 列元素不可重复
/// </summary>
/// <param name="workbook"></param>
/// <param name="columnName">列标题</param>
/// <param name="colString">列坐标</param>
/// <param name="sheetIndex">下拉菜单sheet页索引</param>
/// <param name="firstRowIndex">下拉菜单起始行索引</param>
/// <param name="lastRowIndex">下拉菜单结束行索引</param>
private void CheckListRow(XSSFWorkbook workbook, string columnName, string colString,
int sheetIndex = , int firstRowIndex = , int lastRowIndex = MaxRowIndex)
{
var sheet = workbook.GetSheetAt(sheetIndex);//获取Excel sheet页面
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)sheet);
//根据列坐标获取索引
int colIndex = CellReference.ConvertColStringToIndex((colString ?? "").ToUpper());//根据列坐标获取索引
CellRangeAddressList regions = new CellRangeAddressList(firstRowIndex, , colIndex, colIndex); //选定一个区域 (起始行序号,终止行序号,起始列序号,终止列序号)
XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint)
dvHelper.CreateCustomConstraint(string.Format("COUNTIF(${0}:${0},{0}4)<2", colString));//数据有效性设置 自定义
//COUNTIF($A:$A,A4)<2
XSSFDataValidation validation = (XSSFDataValidation)dvHelper.CreateValidation(dvConstraint, regions);//创建验证
validation.ShowErrorBox = true;//显示出错警告
validation.CreateErrorBox("错误", columnName + "元素重复");//出错警告设置
sheet.AddValidationData(validation);//添加验证 } #endregion #region 由数据源及数据源sheet页生成下拉菜单
/// <summary>
/// 由数据源及数据源sheet页生成下拉菜单
/// </summary>
/// <param name="workbook">XSSFWorkbook</param>
/// <param name="category">category</param>
/// <param name="columnName">列标题</param>
/// <param name="ddlColString">下拉菜单列坐标</param>
/// <param name="dsColString">数据源列坐标</param>
/// <param name="ddlSheetIndex">下拉菜单sheet页索引</param>
/// <param name="dsSheetIndex">数据源sheet页索引</param>
/// <param name="ddlFirstRowIndex">下拉菜单起始行索引</param>
/// <param name="ddlLastRowIndex">下拉菜单结束行索引</param>
/// <param name="dsFirstRowIndex">数据源起始行索引</param>
/// <param name="dsLastRowIndex">数据源结束行索引</param>
private void GenerateCascadingDropdownListRow(XSSFWorkbook workbook, string category, string columnName, string ddlColString,
string dsColString, int ddlSheetIndex = , int dsSheetIndex = , int ddlFirstRowIndex = , int ddlLastRowIndex = MaxRowIndex,
int dsFirstRowIndex = , int dsLastRowIndex = MaxRowIndex)
{
ISheet ddlSheet = workbook.GetSheetAt(ddlSheetIndex);
ISheet dsSheet = workbook.GetSheetAt(dsSheetIndex);
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)ddlSheet);
int ddlColIndex = CellReference.ConvertColStringToIndex((ddlColString ?? "").ToUpper());
int dsColIndex = CellReference.ConvertColStringToIndex((dsColString ?? "").ToUpper()); ICellStyle unblockStyle = workbook.CreateCellStyle();
unblockStyle.IsLocked = false;
((XSSFSheet)dsSheet).GetColumnHelper().SetColDefaultStyle(dsColIndex, unblockStyle); //下拉菜单数据源
string[] data = _tsysCompCodeBusiness.GetCodesByCategoryCode(category).Select(x => x.Item_Name).OrderBy(x => x).ToArray();
IRow titleRow = dsSheet.GetRow() ?? dsSheet.CreateRow();
ICell titleCell = titleRow.GetCell(dsColIndex) ?? titleRow.CreateCell(dsColIndex);
titleCell.SetCellValue(columnName ?? ""); ICellStyle titleStyle = workbook.CreateCellStyle();
if (ddlSheet.GetRow(ddlFirstRowIndex - ) != null)
{
ICellStyle style = ddlSheet.GetRow(ddlFirstRowIndex - ).GetCell(ddlColIndex).CellStyle;
titleStyle.CloneStyleFrom(style);
}
titleCell.CellStyle = titleStyle; titleCell.CellStyle.IsLocked = true;
//下拉菜单数据源
if (data != null && data.Length > )
{
for (int i = ; i < data.Length; i++)
{
IRow row = dsSheet.GetRow(dsFirstRowIndex + i) ?? dsSheet.CreateRow(dsFirstRowIndex + i);
ICell cell = row.GetCell(dsColIndex) ?? row.CreateCell(dsColIndex);
cell.SetCellValue(data[i]);
cell.CellStyle.IsLocked = true;
}
} dsSheet.AutoSizeColumn(dsColIndex);
dsSheet.ProtectSheet("");
IName range = workbook.CreateName();
//range.RefersToFormula = string.Format("{0}!${1}${2}:${1}${3}", dsSheet.SheetName, (dsColString ?? "").ToUpper(), dsFirstRowIndex + 1, dsLastRowIndex);
range.RefersToFormula = string.Format("{0}!${1}${2}:INDEX({0}!${1}${2}:${1}${3},SUMPRODUCT(--({0}!${1}${2}:${1}${3}<>\"\")))", dsSheet.SheetName, (dsColString ?? "").ToUpper(), dsFirstRowIndex + , dsLastRowIndex);
//range.RefersToFormula = string.Format("OFFSET(INDIRECT(\"{0}!${1}${2}\"),0,0,COUNTA({0}!${1}:${1}),1)", dsSheet.SheetName, (dsColString ?? "").ToUpper(), dsFirstRowIndex + 1, dsLastRowIndex);
//string colName = ddlSheet.GetRow(ddlFirstRowIndex - 1).GetCell(ddlColIndex).StringCellValue;
range.NameName = columnName; //下拉菜单约束范围
CellRangeAddressList addressList = new CellRangeAddressList(ddlFirstRowIndex, ddlLastRowIndex, ddlColIndex, ddlColIndex);
XSSFDataValidation validation = (XSSFDataValidation)dvHelper.CreateValidation(dvHelper.CreateFormulaListConstraint(columnName), addressList); validation.ShowErrorBox = true;
validation.CreateErrorBox("错误", columnName + "错误");
ddlSheet.AddValidationData(validation);
} private void GenerateCascadingDropdownListRow(XSSFWorkbook workbook, string[] data, string columnName, string ddlColString,
string dsColString, int ddlSheetIndex = , int dsSheetIndex = , int ddlFirstRowIndex = , int ddlLastRowIndex = MaxRowIndex,
int dsFirstRowIndex = , int dsLastRowIndex = MaxRowIndex)
{
ISheet ddlSheet = workbook.GetSheetAt(ddlSheetIndex);
ISheet dsSheet = workbook.GetSheetAt(dsSheetIndex);
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)ddlSheet);
int ddlColIndex = CellReference.ConvertColStringToIndex((ddlColString ?? "").ToUpper());
int dsColIndex = CellReference.ConvertColStringToIndex((dsColString ?? "").ToUpper()); ICellStyle unblockStyle = workbook.CreateCellStyle();
unblockStyle.IsLocked = false;
((XSSFSheet)dsSheet).GetColumnHelper().SetColDefaultStyle(dsColIndex, unblockStyle); //下拉菜单数据源
IRow titleRow = dsSheet.GetRow() ?? dsSheet.CreateRow();
ICell titleCell = titleRow.GetCell(dsColIndex) ?? titleRow.CreateCell(dsColIndex);
titleCell.SetCellValue(columnName ?? ""); ICellStyle titleStyle = workbook.CreateCellStyle();
if (ddlSheet.GetRow(ddlFirstRowIndex - ) != null)
{
ICellStyle style = ddlSheet.GetRow(ddlFirstRowIndex - ).GetCell(ddlColIndex).CellStyle;
titleStyle.CloneStyleFrom(style);
}
titleCell.CellStyle = titleStyle; titleCell.CellStyle.IsLocked = true;
//下拉菜单数据源
if (data != null && data.Length > )
{
for (int i = ; i < data.Length; i++)
{
IRow row = dsSheet.GetRow(dsFirstRowIndex + i) ?? dsSheet.CreateRow(dsFirstRowIndex + i);
ICell cell = row.GetCell(dsColIndex) ?? row.CreateCell(dsColIndex);
cell.SetCellValue(data[i]);
cell.CellStyle.IsLocked = true;
}
} dsSheet.AutoSizeColumn(dsColIndex);
dsSheet.ProtectSheet("");
IName range = workbook.CreateName();
range.RefersToFormula = string.Format("{0}!${1}${2}:INDEX({0}!${1}${2}:${1}${3},SUMPRODUCT(--({0}!${1}${2}:${1}${3}<>\"\")))", dsSheet.SheetName, (dsColString ?? "").ToUpper(), dsFirstRowIndex + , dsLastRowIndex);
range.NameName = columnName; //下拉菜单约束范围
CellRangeAddressList addressList = new CellRangeAddressList(ddlFirstRowIndex, ddlLastRowIndex, ddlColIndex, ddlColIndex);
XSSFDataValidation validation = (XSSFDataValidation)dvHelper.CreateValidation(dvHelper.CreateFormulaListConstraint(columnName), addressList); validation.ShowErrorBox = true;
validation.CreateErrorBox("错误", columnName + "错误");
ddlSheet.AddValidationData(validation);
}
#endregion #region terpPersonInfo
public ActionResult ExportTerpPersonInfo()
{
string templateFile = "terpPersonInfo.xlsx";
try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
int dsSheetIndex = ;
int ddlSheetIndex = ;
//性别
GenerateDropdownListRow(templateWorkbook, "", "性别", "D", ddlSheetIndex);
//政治面貌
GenerateCascadingDropdownListRow(templateWorkbook, "", "政治面貌", "H", "A", ddlSheetIndex, dsSheetIndex);
//婚姻状况
GenerateDropdownListRow(templateWorkbook, "", "婚姻状况", "F", ddlSheetIndex);
//民族
GenerateCascadingDropdownListRow(templateWorkbook, "", "民族", "I", "B", ddlSheetIndex, dsSheetIndex);
//在职状态
GenerateCascadingDropdownListRow(templateWorkbook, "", "在职状态", "S", "C", ddlSheetIndex, dsSheetIndex);
//最高职称
GenerateCascadingDropdownListRow(templateWorkbook, "", "最高职称", "Y", "D", ddlSheetIndex, dsSheetIndex);
//员工类型
GenerateDropdownListRow(templateWorkbook, "", "员工类型", "T", ddlSheetIndex);
//开户银行
GenerateCascadingDropdownListRow(templateWorkbook, "", "开户银行", "Z", "E", ddlSheetIndex, dsSheetIndex);
//离职类型
GenerateCascadingDropdownListRow(templateWorkbook, "", "离职类型", "AC", "F", ddlSheetIndex, dsSheetIndex);
//户口性质
GenerateCascadingDropdownListRow(templateWorkbook, "", "户口性质", "AG", "G", ddlSheetIndex, dsSheetIndex);
//所属公司
GenerateCascadingDropdownListRow(templateWorkbook, "", "所属公司", "AI", "H", ddlSheetIndex, dsSheetIndex); CheckListRow(templateWorkbook, "员工编号", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TerpPartInfo
private ActionResult ExportTerpPartInfo()
{
string templateFile = "terpPartInfo.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
//单位
GenerateCascadingDropdownListRow(templateWorkbook, "", "单位", "C", "A", , );
//生产性质
GenerateDropdownListRow(templateWorkbook, "", "生产性质", "G", );
//图纸纸张大小
GenerateCascadingDropdownListRow(templateWorkbook, "", "图纸大小", "R", "B", , );
//生产难度
GenerateCascadingDropdownListRow(templateWorkbook, "", "生产难度", "J", "C", , );
//工时分类
string[] data = _terpProductBusiness.GetWorkHourType().OrderBy(x => x.WorkHourCostTypeName).Select(x => x.WorkHourCostTypeName).ToArray();
GenerateDropdownListRow(templateWorkbook, data, "工时分类", "P", );
//所属仓库
string ObjStoreType = "";
string[] StoreNameArray = _terpPartBusiness.GetStoreName(ObjStoreType).OrderBy(x => x.Store_Name).Select(x => x.Store_Name).ToArray();
GenerateDropdownListRow(templateWorkbook, StoreNameArray, "所属仓库", "L", );
//设计者
string[] designArray = _terpPersonInfoBusiness.GetAllActive().Include(x => x.Org).OrderBy(x => x.EmployeeName).Select(x => x.EmployeeName).ToArray();
GenerateDropdownListRow(templateWorkbook, designArray, "设计者", "X", );
//审核者
string[] verifyArray = _terpPersonInfoBusiness.GetAllActive().Include(x => x.Org).OrderBy(x => x.EmployeeName).Select(x => x.EmployeeName).ToArray();
GenerateDropdownListRow(templateWorkbook, verifyArray, "审核者", "Z", ); CheckListRow(templateWorkbook, "编码", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TerpProductBase 更名terpProductInfo
private ActionResult ExportTerpProductBase()
{
// string templateFile = "terpProductBase.xlsx";
string templateFile = "terpProductInfo.xlsx";
try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
//单位
GenerateCascadingDropdownListRow(templateWorkbook, "", "单位", "C", "A", , );
//生产难度
GenerateCascadingDropdownListRow(templateWorkbook, "", "生产难度", "J", "B", , );
//图纸大小
GenerateCascadingDropdownListRow(templateWorkbook, "", "图纸大小", "Q", "C", , );
//产品分类
GenerateCascadingDropdownListRow(templateWorkbook, "", "产品分类", "D", "D", , );
//工时分类
string[] data = _terpProductBusiness.GetWorkHourType().OrderBy(x => x.WorkHourCostTypeName).Select(x => x.WorkHourCostTypeName).ToArray();
GenerateDropdownListRow(templateWorkbook, data, "工时分类", "O", );
//所属仓库
string ObjStoreType = "";
string[] StoreNameArray = _terpPartBusiness.GetStoreName(ObjStoreType).OrderBy(x => x.Store_Name).Select(x => x.Store_Name).ToArray();
GenerateDropdownListRow(templateWorkbook, StoreNameArray, "所属仓库", "L", );
//设计者
string[] designArray = _terpPersonInfoBusiness.GetAllActive().Include(x => x.Org).OrderBy(x => x.EmployeeName).Select(x => x.EmployeeName).ToArray();
GenerateDropdownListRow(templateWorkbook, designArray, "设计者", "W", );
//审核者
string[] verifyArray = _terpPersonInfoBusiness.GetAllActive().Include(x => x.Org).OrderBy(x => x.EmployeeName).Select(x => x.EmployeeName).ToArray();
GenerateDropdownListRow(templateWorkbook, verifyArray, "审核者", "Y", ); CheckListRow(templateWorkbook, "编码", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TerpMaterialBase
private ActionResult ExportTerpMaterialBase()
{
string templateFile = "terpMaterialBase.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
//核算用单位
GenerateCascadingDropdownListRow(templateWorkbook, "", "核算用单位", "E", "A", , );
//非核算用单位
GenerateCascadingDropdownListRow(templateWorkbook, "", "非核算用单位", "F", "B", , );
//所属仓库
string ObjStoreType = "";
string[] StoreNameArray = _terpPartBusiness.GetStoreName(ObjStoreType).OrderBy(x => x.Store_Name).Select(x => x.Store_Name).ToArray();
GenerateDropdownListRow(templateWorkbook, StoreNameArray, "仓库名称", "G", ); CheckListRow(templateWorkbook, "原材料编号", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TsysCompOrg
private ActionResult ExportTsysCompOrg()
{
string templateFile = "tsysCompOrg.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
CheckListRow(templateWorkbook, "组织机构编码", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TsysCompRole
private ActionResult ExportTsysCompRole()
{
string templateFile = "tsysCompRole.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); GenerateDropdownListRow(templateWorkbook, "", "角色类型", "C", );
CheckListRow(templateWorkbook, "角色编码", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TerpSupplyBase 物品表
private ActionResult ExportTerpSupplyBase()
{
string templateFile = "terpSupplyBase.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); GenerateCascadingDropdownListRow(templateWorkbook, "", "单位", "C", "A", , ); GenerateCascadingDropdownListRow(templateWorkbook, "", "物品用途分类", "I", "B", , ); GenerateDropdownListRow(templateWorkbook, "", "生产性质", "J", ); GenerateDropdownListRow(templateWorkbook, "", "借领分类", "K", ); GenerateDropdownListRow(templateWorkbook, "", "领用审批", "M", );
//所属仓库
string ObjStoreType = "";
string[] StoreNameArray = _terpPartBusiness.GetStoreName(ObjStoreType).OrderBy(x => x.Store_Name).Select(x => x.Store_Name).ToArray();
GenerateDropdownListRow(templateWorkbook, StoreNameArray, "仓库名称", "G", ); CheckListRow(templateWorkbook, "物品编号", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TsysUser
private ActionResult ExportTsysUser()
{
string templateFile = "tsysUser.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); int ddlSheetIndex = ; GenerateDropdownListRow(templateWorkbook, "", "性别", "C", ddlSheetIndex);
//系统角色
string[] data = _tsysCompCodeBusiness.GetCodesByCategoryCodeCompanyId("").Where(x => x.Item_Code != "").Select(x => x.Item_Name).OrderBy(x => x).ToArray();
GenerateDropdownListRow(templateWorkbook, data, "系统角色", "I", ddlSheetIndex);
//TsysUserDropdownListRow(templateWorkbook, "087", "系统角色", "J", ddlSheetIndex); //角色名
string[] roles = _tsysCompRoleBusiness.GetAllRole().Select(x => x.Role_Name).OrderBy(x => x).ToArray();
GenerateDropdownListRow(templateWorkbook, roles, "角色名称", "J", ddlSheetIndex); CheckListRow(templateWorkbook, "员工号", "B");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TsysUserRole
private ActionResult ExportTsysUserRole()
{
string templateFile = "tsysUserRole.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TerpWorkHourCostTypeId
private ActionResult ExportTerpWorkHourCostTypeId()
{
string templateFile = "TerpWorkHourCostTypeId.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
CheckListRow(templateWorkbook, "工时费分类编码", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
} }
#endregion #region TerpTechUseMaterialDF
private ActionResult ExportTerpTechUseMaterialDF()
{
string templateFile = "terpTechUseMaterialDF.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
} #endregion #region TerpSupplierInfo
private ActionResult ExportTerpSupplierInfo()
{
string templateFile = "terpSupplierInfo.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); //公司性质
GenerateCascadingDropdownListRow(templateWorkbook, "", "公司性质", "D", "A", , );
//行业类别
GenerateCascadingDropdownListRow(templateWorkbook, "", "行业类别", "E", "B", , );
//供应商分类
GenerateDropdownListRow(templateWorkbook, "", "供应商分类", "G", );
//供应商分级
GenerateCascadingDropdownListRow(templateWorkbook, "", "供应商分级", "J", "C", , ); CheckListRow(templateWorkbook, "供应商编码", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TerpDesignBom更名terpProductDesignBom
private ActionResult ExportTerpDesignBom()
{
// string templateFile = "terpDesignBom.xlsx";
string templateFile = "terpProductDesignBom.xlsx";
try
{
//using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
//{
// XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); // using (MemoryStream ms = new MemoryStream())
// {
// templateWorkbook.Write(ms);
// return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
// }
//}
return File(string.Format("{0}{1}", TemplatePath, templateFile), "application/vnd.ms-excel", templateFile);
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TerpDesignBomPartRelation 更名terpPartRelation private ActionResult ExportTerpDesignBomPartRelation()
{
//string templateFile = "terpDesignBomPartRelation.xlsx";
string templateFile = "terpPartRelation.xlsx"; try
{
//using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
//{
// XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); // using (MemoryStream ms = new MemoryStream())
// {
// templateWorkbook.Write(ms);
// return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
// }
//}
return File(string.Format("{0}{1}", TemplatePath, templateFile), "application/vnd.ms-excel", templateFile);
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region tsysStoreInfo 仓库表
private ActionResult ExportTsysStoreInfo()
{
string templateFile = "tsysStoreInfo.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs); GenerateDropdownListRow(templateWorkbook, "", "仓库类型", "C", ); CheckListRow(templateWorkbook, "仓库编码", "A");
CheckListRow(templateWorkbook, "仓库名称", "B");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region tsysStorePartition 仓库库位划分表
private ActionResult ExportTsysStorePartition()
{
string templateFile = "tsysStorePartition.xlsx"; try
{
//using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
//{
// XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
// using (MemoryStream ms = new MemoryStream())
// {
// templateWorkbook.Write(ms);
// return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
// }
//}
return File(string.Format("{0}{1}", TemplatePath, templateFile), "application/vnd.ms-excel", templateFile);
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region tsysStoreLocation 仓库库位管理
private ActionResult ExportTsysStoreLocation()
{
string templateFile = "tsysStoreLocation.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
GenerateDropdownListRow(templateWorkbook, "", "库位状态", "D", );
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region tcrmCustomerInfo 客户信息表
private ActionResult ExportTcrmCustomerInfo()
{
string templateFile = "tcrmCustomerInfo.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
GenerateCascadingDropdownListRow(templateWorkbook, "", "公司性质", "E", "A", , );
GenerateCascadingDropdownListRow(templateWorkbook, "", "行业类别", "G", "B", , );
GenerateCascadingDropdownListRow(templateWorkbook, "", "发货方式", "O", "C", , );
GenerateCascadingDropdownListRow(templateWorkbook, "", "成交方式", "R", "D", , );
GenerateCascadingDropdownListRow(templateWorkbook, "", "结算方式", "T", "E", , );
GenerateCascadingDropdownListRow(templateWorkbook, "", "客户分类", "Z", "F", , );
GenerateCascadingDropdownListRow(templateWorkbook, "", "客户分级", "AA", "G", , );
//所在地区
string[] regionArray = _tsysManagementBusiness.GetAllTsysCompRegion(_dcContext.CurrentUser.CompanyId.ToString()).Where(x => x.Region_Name != "全部地区").Select(x => x.Region_Name).OrderBy(x => x).ToArray();
GenerateDropdownListRow(templateWorkbook, regionArray, "所在地区", "I", );
//我方负责人
string[] responsPeopleArray = _terpPersonInfoBusiness.GetAllActive().Include(x => x.Org).OrderBy(x => x.EmployeeName).Select(x => x.EmployeeName).ToArray();
//string[] responsPeopleArray = _tsysManagementBusiness.GetAllTsysUser(_dcContext.CurrentUser.CompanyId.ToString()).Select(x => x.UserName).OrderBy(x => x).ToArray();
GenerateDropdownListRow(templateWorkbook, responsPeopleArray, "我方负责人", "Y", );
CheckListRow(templateWorkbook, "客户编码", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region terpPartInStoreInfo 仓库分库存表
private ActionResult ExportTerpPartInStoreInfo()
{
string templateFile = "terpPartInStoreInfo.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
GenerateDropdownListRow(templateWorkbook, "", "实际仓库类型", "B", );
GenerateDropdownListRow(templateWorkbook, "", "基本仓库类型", "G", );
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region TerpPartTotolStoreInfo 总库存
private ActionResult ExportTerpPartTotolStoreInfo()
{
string templateFile = "terpPartTotolStoreInfo.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
//实际仓库类型
GenerateDropdownListRow(templateWorkbook, "", "实际仓库类型", "B", ); //基本仓库类型
GenerateDropdownListRow(templateWorkbook, "", "基本仓库类型", "E", ); CheckListRow(templateWorkbook, "编码", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region tsasAgentRegister 合作伙伴
private ActionResult ExportTsasAgentRegister()
{
string templateFile = "tsasAgentRegister.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
CheckListRow(templateWorkbook, "公司名称", "A");
CheckListRow(templateWorkbook, "登录标识", "I"); //销售代表
string[] salesPersonArray = _tsysUserBusiness.GetAllActive().OrderBy(x => x.UserName).Select(x => x.UserName).ToArray();
GenerateDropdownListRow(templateWorkbook, salesPersonArray, "销售代表", "G", );
//服务状态
GenerateCascadingDropdownListRow(templateWorkbook, "", "服务状态", "H", "A", , );
//授权类型
string[] useStateAgentArray = {"试用","正式" };
GenerateDropdownListRow(templateWorkbook, useStateAgentArray, "授权类型", "L", ); using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region tsasRegCompServiceNote 服务记录
private ActionResult ExportTsasRegCompServiceNote()
{
string templateFile = "tsasRegCompServiceNote.xlsx"; try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
//服务状态
GenerateCascadingDropdownListRow(templateWorkbook, "", "服务状态", "D", "A", , ); using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
}
}
#endregion #region terpQuoteMnt 报价信息 private ActionResult ExportTerpQuoteMnt()
{
string templateFile = "terpQuoteMnt.xlsx";
try
{
using (FileStream fs = new FileStream(Server.MapPath(string.Format("{0}{1}", TemplatePath, templateFile)), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
XSSFWorkbook templateWorkbook = new XSSFWorkbook(fs);
int ddlSheetIndex = ;
//报价模板
GenerateDropdownListRow(templateWorkbook, GetTempleteArry(), "报价模板", "B", ddlSheetIndex); CheckListRow(templateWorkbook, "客户名称", "A");
using (MemoryStream ms = new MemoryStream())
{
templateWorkbook.Write(ms);
return File(ms.ToArray(), "application/vnd.ms-excel", templateFile);
}
}
}
catch (Exception ex)
{
return View(ex.Message);
} }
/// <summary>
/// 获取模板数组
/// </summary>
/// <returns></returns>
private string[] GetTempleteArry()
{
var list= _terpQuotedPriceTemplateBusiness.GetAllActive().ToList();
List<string> arry=new List<string>();
for (int i = ; i < list.Count; i++)
{
arry.Add(list[i].TemplateName);
}
return arry.ToArray();
} #endregion
}
}
4。判断Excel是否格式正确,格式正确上传
NPOI 上传Excel功能的更多相关文章
-
NPOI 上传Excel功能(三)
4.验证Excel并上传 using DC.BE.Business.SAS; using DC.BE.Business.SYS; using DC.BE.Entity.SAS; using DC.BE ...
-
NPOI 上传Excel功能(二)
3.上传文件,写入log using DC.BE.Business.SYS; using DC.BE.Entity.ERP; using DC.BE.Entity.SAS; using DC.BE.E ...
-
ASP.NET Core 2.2 : 十六.扒一扒新的Endpoint路由方案 try.dot.net 的正确使用姿势 .Net NPOI 根据excel模板导出excel、直接生成excel .Net NPOI 上传excel文件、提交后台获取excel里的数据
ASP.NET Core 2.2 : 十六.扒一扒新的Endpoint路由方案 ASP.NET Core 从2.2版本开始,采用了一个新的名为Endpoint的路由方案,与原来的方案在使用上差别不 ...
-
.Net NPOI 上传excel文件、提交后台获取excel里的数据
1.导入NPOI.dll 2.添加类NPOIExcel.cs using System; using System.Collections.Generic; using System.Text; us ...
-
文件一键上传、汉字转拼音、excel文件上传下载功能模块的实现
----------------------------------------------------------------------------------------------[版权申明: ...
-
微信小程序上传Excel文本文件功能
问题: 在开发过程中会发现微信小程序有很多功能都还不能满足我们的需求,谁叫客户就是上帝呢,前几天小编遇到了这么个问题,就是用微信小程序上传文件,但是还以为微信带有这个模块,可是查了许久还是没有找到,只 ...
-
java的poi技术下载Excel模板上传Excel读取Excel中内容(SSM框架)
使用到的jar包 JSP: client.jsp <%@ page language="java" contentType="text/html; charset= ...
-
WEB文件上传下载功能
WEB文件上传下载在日常工作中经常用到的功能 这里用到JS库 http://files.cnblogs.com/meilibao/ajaxupload.3.5.js 上传代码段(HTML) <% ...
-
java上传excel到后台解析入库
背景:最近需要做一个excel模板导入的功能,以便用户可以自己增删改查数据,当然,只有特别的用户才能有此权限,捋了捋思路,还是从前端写起 实现: 页面最后的效果如下,可以自己修改,删除,导入导出数据, ...
随机推荐
-
Hadoop伪分布式集群环境搭建
本教程讲述在单机环境下搭建Hadoop伪分布式集群环境,帮助初学者方便学习Hadoop相关知识. 首先安装Hadoop之前需要准备安装环境. 安装Centos6.5(64位).(操作系统再次不做过多描 ...
-
oracle EXP导出一张表时使用query参数指定where条件
oracle exp 导出一个表的部分内容,使用query参数可加上SQL的where条件进行过滤 注意:如果需要使用到日期字符串格式等单引号,需要使用双引号将where条件括起来,而且双引号要用\做 ...
-
C#读写ini文件操作
ini文件,是windows操作系统下的配置文件,ini文件是一种按照特点方式排列的文本文件,它的构成分为三部分,结构如下: [Section1] key 1 = value2 key 1 = val ...
-
MYSQL中replace into的用法以及与inset into的区别
在向表中插入数据时,我们经常会遇到这样的情况:1.首先判断数据是否存在:2.如果不存在,则插入:3.如果存在,则更新. 在SQL Server中可以这样处理: if not exists (selec ...
-
IIS 之 添加MIME扩展类型及常用的MIME类型列表
经常用IIS作为下载服务器的时候有时传上去的文件比如 example.mp4 文件名上传后,但是用http打开的时候确显示为 404 文件不存在.其实是IIS对文件的一种保护,不在IIS指定的MIME ...
-
从某一日期开始过day天的日期
一个SX问我的,我就写了写......从2010.1.1开始,给了一组测试数据3的话输出2010.1.4星期1,所以说2010.1.1是星期五,总星期就是 (day+5)%7==0?7:(day+5) ...
-
12.04 ubuntu 更改IP
在一个局域网里面,如果是自动获取IP,就会导致IP冲突 进入要连接的热点进行设置 IPV4 Setting address netmask ...
-
记录easyui一些用法
自己备注,省的之后忘记.用到一个写一个,不断添加 1.form里的一些控件如textbox.combobox等添加额外的一些事件,如鼠标事件(mouseover.click等),键盘事件(keydow ...
-
linux 内核的优化
修改下面的这些参数,如果没有的话.直接复制进去就可以了 vim /etc/sysctl.conf 参数修改 vm.swappiness = net.ipv4.neigh. net.ipv4.conf. ...
-
python 日常代码 tips
1. 官方示例很多情况是用的列表的形式,bokeh本身不是基于pandas构建的可视化工具,所以它基本上是用的python自己的数据结构字典.列表:我们做数据分析肯定是基于pandas,以上就是做了一 ...