MiniExcel/drafts/【MiniExcel】Minify XML.linq
2021-03-25 16:10:24 +08:00

81 lines
3.4 KiB
C#

<Query Kind="Program">
<NuGetReference>Dapper</NuGetReference>
<NuGetReference>MiniExcel</NuGetReference>
<NuGetReference>Newtonsoft.Json</NuGetReference>
<NuGetReference>System.Data.SqlClient</NuGetReference>
<Namespace>MiniExcelLibs</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<RemoveNamespace>System.Data</RemoveNamespace>
<RemoveNamespace>System.Diagnostics</RemoveNamespace>
<RemoveNamespace>System.Linq.Expressions</RemoveNamespace>
<RemoveNamespace>System.Text</RemoveNamespace>
<RemoveNamespace>System.Text.RegularExpressions</RemoveNamespace>
<RemoveNamespace>System.Threading</RemoveNamespace>
<RemoveNamespace>System.Transactions</RemoveNamespace>
<RemoveNamespace>System.Xml</RemoveNamespace>
<RemoveNamespace>System.Xml.Linq</RemoveNamespace>
<RemoveNamespace>System.Xml.XPath</RemoveNamespace>
</Query>
void Main()
{
Console.WriteLine(DefualtXml.DefaultRels);
}
// You can define other methods, fields, classes and namespaces here
public class DefualtXml
{
internal 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 DefaultSheetXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<x:worksheet xmlns:x=""http://schemas.openxmlformats.org/spreadsheetml/2006/main"">
<x:sheetData>
</x:sheetData>
</x:worksheet>";
internal static string DefaultWorkbookXmlRels = @"<?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/worksheet"" Target=""/xl/worksheets/sheet1.xml"" Id=""R1274d0d920f34a32"" />
<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""?>
<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 numFmtId=""14"" applyNumberFormat=""1"" />
</x:cellXfs>
</x:styleSheet>";
internal 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>
<x:sheet xmlns:r=""http://schemas.openxmlformats.org/officeDocument/2006/relationships"" name=""Sheet1"" sheetId=""1"" r:id=""R1274d0d920f34a32"" />
</x:sheets>
</x:workbook>";
static DefualtXml()
{
DefaultRels = MinifyXml(DefaultRels);
DefaultWorkbookXml = MinifyXml(DefaultWorkbookXml);
DefaultStylesXml = MinifyXml(DefaultStylesXml);
DefaultWorkbookXmlRels = MinifyXml(DefaultWorkbookXmlRels);
DefaultSheetXml = MinifyXml(DefaultSheetXml);
}
private static string MinifyXml(string xml) => xml.Replace(" ","").Replace("\r","").Replace("\n","").Replace("\t","");
}