mirror of
https://gitee.com/dotnetchina/MiniExcel.git
synced 2024-11-29 18:38:08 +08:00
code refactoring
This commit is contained in:
parent
2c920d6dc7
commit
7fd2d3ebfd
10
README.md
10
README.md
@ -999,12 +999,12 @@ private IEnumerable<Dictionary<string, object>> GetOrders(string lang, string ro
|
||||
|
||||
if (lang == "zh-CN")
|
||||
{
|
||||
newOrder.Add("客戶編號", order.CustomerID);
|
||||
newOrder.Add("訂單編號", order.OrderNo);
|
||||
newOrder.Add("產品編號", order.ProductID);
|
||||
newOrder.Add("數量", order.Qty);
|
||||
newOrder.Add("客户编号", order.CustomerID);
|
||||
newOrder.Add("订单编号", order.OrderNo);
|
||||
newOrder.Add("产品编号", order.ProductID);
|
||||
newOrder.Add("数量", order.Qty);
|
||||
if (role == "Sales")
|
||||
newOrder.Add("價格", order.Amt);
|
||||
newOrder.Add("价格", order.Amt);
|
||||
yield return newOrder;
|
||||
}
|
||||
else if (lang == "en-US")
|
||||
|
@ -12,18 +12,40 @@ namespace MiniExcelLibs.OpenXml
|
||||
{
|
||||
private readonly static UTF8Encoding Utf8WithBom = new System.Text.UTF8Encoding(true);
|
||||
|
||||
internal static string DefaultRels = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
private static string DefaultRels = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<Relationships xmlns=""http://schemas.openxmlformats.org/package/2006/relationships"">
|
||||
<Relationship Type=""http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"" Target=""/xl/workbook.xml"" Id=""Rfc2254092b6248a9"" />
|
||||
</Relationships>";
|
||||
|
||||
internal static string DefaultWorkbookXmlRels = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
private static string DefaultWorkbookXmlRels = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<Relationships xmlns=""http://schemas.openxmlformats.org/package/2006/relationships"">
|
||||
{{sheets}}
|
||||
<Relationship Type=""http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"" Target=""/xl/styles.xml"" Id=""R3db9602ace774fdb"" />
|
||||
</Relationships>";
|
||||
|
||||
internal static string DefaultStylesXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
private static string NoneStylesXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<x:styleSheet xmlns:x=""http://schemas.openxmlformats.org/spreadsheetml/2006/main"">
|
||||
<x:fonts>
|
||||
<x:font />
|
||||
</x:fonts>
|
||||
<x:fills>
|
||||
<x:fill />
|
||||
</x:fills>
|
||||
<x:borders>
|
||||
<x:border />
|
||||
</x:borders>
|
||||
<x:cellStyleXfs>
|
||||
<x:xf />
|
||||
</x:cellStyleXfs>
|
||||
<x:cellXfs>
|
||||
<x:xf />
|
||||
<x:xf />
|
||||
<x:xf />
|
||||
<x:xf numFmtId=""14"" applyNumberFormat=""1"" />
|
||||
</x:cellXfs>
|
||||
</x:styleSheet>";
|
||||
|
||||
private static string DefaultStylesXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<x:styleSheet xmlns:x=""http://schemas.openxmlformats.org/spreadsheetml/2006/main"">
|
||||
<x:numFmts count=""1"">
|
||||
<x:numFmt numFmtId=""0"" formatCode="""" />
|
||||
@ -124,7 +146,7 @@ namespace MiniExcelLibs.OpenXml
|
||||
</x:cellStyles>
|
||||
</x:styleSheet>";
|
||||
|
||||
internal static string DefaultWorkbookXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
private static string DefaultWorkbookXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<x:workbook xmlns:r=""http://schemas.openxmlformats.org/officeDocument/2006/relationships""
|
||||
xmlns:x=""http://schemas.openxmlformats.org/spreadsheetml/2006/main"">
|
||||
<x:sheets>
|
||||
@ -132,7 +154,6 @@ namespace MiniExcelLibs.OpenXml
|
||||
</x:sheets>
|
||||
</x:workbook>";
|
||||
|
||||
|
||||
private static Dictionary<string, XmlDocument> Xmls = new Dictionary<string, XmlDocument>();
|
||||
|
||||
private static readonly XmlNamespaceManager _ns;
|
||||
@ -174,27 +195,7 @@ namespace MiniExcelLibs.OpenXml
|
||||
|
||||
if (configuration.TableStyles == TableStyles.None)
|
||||
{
|
||||
styleXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<x:styleSheet xmlns:x=""http://schemas.openxmlformats.org/spreadsheetml/2006/main"">
|
||||
<x:fonts>
|
||||
<x:font />
|
||||
</x:fonts>
|
||||
<x:fills>
|
||||
<x:fill />
|
||||
</x:fills>
|
||||
<x:borders>
|
||||
<x:border />
|
||||
</x:borders>
|
||||
<x:cellStyleXfs>
|
||||
<x:xf />
|
||||
</x:cellStyleXfs>
|
||||
<x:cellXfs>
|
||||
<x:xf />
|
||||
<x:xf />
|
||||
<x:xf />
|
||||
<x:xf numFmtId=""14"" applyNumberFormat=""1"" />
|
||||
</x:cellXfs>
|
||||
</x:styleSheet>";
|
||||
styleXml = NoneStylesXml;
|
||||
}
|
||||
else if (configuration.TableStyles == TableStyles.Default)
|
||||
{
|
||||
|
@ -73,19 +73,6 @@ namespace MiniExcelLibs.OpenXml
|
||||
}
|
||||
}
|
||||
|
||||
//public void AddSheet(object value, string sheetName, bool printHeader, IConfiguration configuration)
|
||||
//{
|
||||
// //TODO:update
|
||||
// using (var archive = new MiniExcelZipArchive(_stream, ZipArchiveMode.Create, true, _utf8WithBom))
|
||||
// {
|
||||
// var packages = DefualtOpenXml.GenerateDefaultOpenXml(archive, sheetName);
|
||||
// var sheetPath = "xl/worksheets/sheet1.xml";
|
||||
// CreateSheetXml(value, printHeader, archive, packages, sheetPath);
|
||||
// GenerateContentTypesXml(archive, packages);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
private void CreateSheetXml(object value, bool printHeader, MiniExcelZipArchive archive, Dictionary<string, ZipPackageInfo> packages, string sheetPath)
|
||||
{
|
||||
ZipArchiveEntry entry = archive.CreateEntry(sheetPath);
|
||||
|
Loading…
Reference in New Issue
Block a user