Commit d75a0f0e authored by 黄奎's avatar 黄奎

11

parent 4fc88d0d
using NPOI.HSSF.UserModel; using NPOI.SS.Formula.Eval;
using NPOI.SS.Formula.Eval;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Mall.Common.Plugin namespace Mall.Common.Plugin
...@@ -41,7 +38,7 @@ namespace Mall.Common.Plugin ...@@ -41,7 +38,7 @@ namespace Mall.Common.Plugin
/// <param name="needHeader">列头</param> /// <param name="needHeader">列头</param>
/// <param name="imgColList">图片所在的列</param> /// <param name="imgColList">图片所在的列</param>
/// <returns></returns> /// <returns></returns>
public DataTable ExcelToDataTable(String strFileName, int SheetIndex, int HeaderRowIndex, bool needHeader, List<int> imgColList = null) public DataTable ExcelToDataTable(String strFileName, int SheetIndex, int HeaderRowIndex, bool needHeader, List<int> imgColList = null)
{ {
//图片位置数据 //图片位置数据
List<Tuple<int, int, string>> pictureList = new List<Tuple<int, int, string>>(); List<Tuple<int, int, string>> pictureList = new List<Tuple<int, int, string>>();
...@@ -77,12 +74,10 @@ namespace Mall.Common.Plugin ...@@ -77,12 +74,10 @@ namespace Mall.Common.Plugin
int cellCount; int cellCount;
try try
{ {
if (HeaderRowIndex < 0 || !needHeader) if (HeaderRowIndex < 0 || !needHeader)
{ {
headerRow = sheet.GetRow(0); headerRow = sheet.GetRow(0);
cellCount = headerRow.LastCellNum; cellCount = headerRow.LastCellNum;
for (int i = headerRow.FirstCellNum; i <= cellCount; i++) for (int i = headerRow.FirstCellNum; i <= cellCount; i++)
{ {
DataColumn column = new DataColumn(Convert.ToString(i)); DataColumn column = new DataColumn(Convert.ToString(i));
...@@ -107,7 +102,6 @@ namespace Mall.Common.Plugin ...@@ -107,7 +102,6 @@ namespace Mall.Common.Plugin
DataColumn column = new DataColumn(Convert.ToString(i)); DataColumn column = new DataColumn(Convert.ToString(i));
table.Columns.Add(column); table.Columns.Add(column);
} }
} }
else if (table.Columns.IndexOf(headerRow.GetCell(i).ToString()) > 0) else if (table.Columns.IndexOf(headerRow.GetCell(i).ToString()) > 0)
{ {
...@@ -121,7 +115,6 @@ namespace Mall.Common.Plugin ...@@ -121,7 +115,6 @@ namespace Mall.Common.Plugin
} }
} }
} }
int rowCount = sheet.LastRowNum; int rowCount = sheet.LastRowNum;
for (int i = (HeaderRowIndex + 1); i <= sheet.LastRowNum; i++) for (int i = (HeaderRowIndex + 1); i <= sheet.LastRowNum; i++)
...@@ -237,61 +230,7 @@ namespace Mall.Common.Plugin ...@@ -237,61 +230,7 @@ namespace Mall.Common.Plugin
} }
return table; return table;
} }
//public void ExcelToString(string filePath)
//{
// Console.WriteLine("开始.............");
// // 解压Excel文件
// ExtarctExcel(filePath);
// // 先读出图片对应位置
// List<Tuple<int, int, string>> PictureInfo = FindPicCell();
// IWorkbook wk = null;
// string extension = Path.GetExtension(filePath); // 接收文件扩展名,需要判断.xls还是.xlsx
// using (FileStream fs = File.OpenRead(filePath))
// {
// if (extension.Equals(".xls"))
// {
// wk = new HSSFWorkbook(fs);
// }
// if (extension.Equals(".xlsx"))
// {
// wk = new XSSFWorkbook(fs);
// }
// // 读取数据
// ISheet sheet = wk.GetSheetAt(0); // 读当前表
// IRow row = sheet.GetRow(0); // 读当前行
// // LastRowNum是当前表的总行
// int offset = 0;
// for (int i = 0; i < sheet.LastRowNum; i++)
// {
// row = sheet.GetRow(i); // 循环读取每一个行
// if (row != null)
// {
// // LastCellNum是当前行的总列数
// for (int j = 0; j < row.LastCellNum; j++)
// {
// // 读取该cell的数据
// string value = row.GetCell(j).ToString();
// Console.Write(value + " ");
// }
// Console.WriteLine();
// }
// }
// // 读取图片数据List中的图片及Cell位置
// foreach (var picInfo in PictureInfo)
// {
// Console.WriteLine("row: " + picInfo.Item1 + " column: " + picInfo.Item2 + " ,path: " + picInfo.Item3);
// }
// }
// Console.WriteLine("完成!");
// // 这里可以开始下一步操作,save to DB or other.
//}
/// <summary> /// <summary>
/// 解压Excel文件 /// 解压Excel文件
...@@ -373,6 +312,11 @@ namespace Mall.Common.Plugin ...@@ -373,6 +312,11 @@ namespace Mall.Common.Plugin
return PictureInfo; return PictureInfo;
} }
/// <summary>
/// 获取图片位置
/// </summary>
/// <param name="PictureTargetList"></param>
/// <param name="_id"></param>
private void FindPicPathByID(ref List<Tuple<string, string>> PictureTargetList, int _id = 1) private void FindPicPathByID(ref List<Tuple<string, string>> PictureTargetList, int _id = 1)
{ {
string _file = Path.Combine(RootPath, $"xl/drawings/_rels/drawing{_id}.xml.rels"); // 图片对应关系文件 string _file = Path.Combine(RootPath, $"xl/drawings/_rels/drawing{_id}.xml.rels"); // 图片对应关系文件
......
This diff is collapsed.
...@@ -1314,8 +1314,8 @@ namespace Mall.WebApi.Controllers.User ...@@ -1314,8 +1314,8 @@ namespace Mall.WebApi.Controllers.User
JObject parms = JObject.Parse(RequestParm.msg.ToString()); JObject parms = JObject.Parse(RequestParm.msg.ToString());
ResultPageModel pageModel = new ResultPageModel() ResultPageModel pageModel = new ResultPageModel()
{ {
pageIndex=parms.GetInt("pageIndex"), pageIndex = parms.GetInt("pageIndex"),
pageSize=parms.GetInt("pageSize") pageSize = parms.GetInt("pageSize")
}; };
var query = new RB_Menu_Extend() var query = new RB_Menu_Extend()
{ {
...@@ -1509,8 +1509,8 @@ namespace Mall.WebApi.Controllers.User ...@@ -1509,8 +1509,8 @@ namespace Mall.WebApi.Controllers.User
JObject parms = JObject.Parse(RequestParm.msg.ToString()); JObject parms = JObject.Parse(RequestParm.msg.ToString());
ResultPageModel pageModel = new ResultPageModel() ResultPageModel pageModel = new ResultPageModel()
{ {
pageIndex=parms.GetInt("pageIndex"), pageIndex = parms.GetInt("pageIndex"),
pageSize=parms.GetInt("pageSize"), pageSize = parms.GetInt("pageSize"),
}; };
var query = new RB_Miniprogram_PageManage_Extend() var query = new RB_Miniprogram_PageManage_Extend()
{ {
...@@ -2013,7 +2013,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -2013,7 +2013,7 @@ namespace Mall.WebApi.Controllers.User
var query = JsonConvert.DeserializeObject<StatisticsQuery>(RequestParm.msg.ToString()); var query = JsonConvert.DeserializeObject<StatisticsQuery>(RequestParm.msg.ToString());
query.MallBaseId = RequestParm.MallBaseId; query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId; query.TenantId = RequestParm.TenantId;
var obj = programModule.GetMallIndexDataModule(query); var obj = programModule.GetMallIndexDataModule(query);
return ApiResult.Success(data: obj); return ApiResult.Success(data: obj);
} }
...@@ -2229,10 +2229,35 @@ namespace Mall.WebApi.Controllers.User ...@@ -2229,10 +2229,35 @@ namespace Mall.WebApi.Controllers.User
public ApiResult TestYBBrandImport() public ApiResult TestYBBrandImport()
{ {
string rootPath = Path.Combine(Directory.GetCurrentDirectory(), "upfile"); string rootPath = Path.Combine(Directory.GetCurrentDirectory(), "upfile");
string filePath = rootPath + @"\消费品牌.xlsx";
string tempPath = rootPath + @"\TempImport\TempFile"; string tempPath = rootPath + @"\TempImport\TempFile";
var list = BrandHelper.ImportYBBrandData(filePath, tempPath); JObject parms = JObject.Parse(RequestParm.msg.ToString());
return ApiResult.Success(data: Common.Plugin.JsonHelper.Serialize(list));
int Type = parms.GetInt("1");
if (Type == 1)
{
string brandFile = rootPath + @"\消费品牌导入.xlsx";
var brandList = BrandHelper.ImportYBBrandData(brandFile, tempPath);
return ApiResult.Success(data: brandList);
}
else if (Type == 2)
{
string carrierFile = rootPath + @"\商业载体导入.xlsx";
var carrierList = CarrierHelper.ImportYBCarrierData(carrierFile, tempPath);
return ApiResult.Success(data: carrierList);
}
else if (Type == 3)
{
string buildingFile = rootPath + @"\活力楼宇导入.xlsx";
var buildingList = BuildingHelper.ImportYBuildingData(buildingFile, tempPath);
return ApiResult.Success(data: buildingList);
}
else
{
string enterpriseFile = rootPath + @"\企业服务导入.xlsx";
var enterpriseList = EnterpriseServiceHelper.ImportYBEnterpriseData(enterpriseFile, tempPath);
return ApiResult.Success(data: enterpriseList);
}
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment