MiniExcel
MiniExcel copied to clipboard
Create support sharedStrings

xl\worksheets\sheet1.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3"
xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"
xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision"
xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"
xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{81C7CFAE-5086-4E08-9176-FEC8F61D9FA2}">
<dimension ref="A1:B2"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0">
<selection activeCell="B2" sqref="B2"/>
</sheetView>
</sheetViews>
<sheetFormatPr defaultRowHeight="14.4" x14ac:dyDescent="0.3"/>
<cols>
<col min="1" max="1" width="13.21875" customWidth="1"/>
<col min="2" max="2" width="8.88671875" customWidth="1"/>
</cols>
<sheetData>
<row r="1" spans="1:2" x14ac:dyDescent="0.3">
<c r="A1" t="s">
<v>0</v>
</c>
<c r="B1">
<v>123456</v>
</c>
</row>
<row r="2" spans="1:2" x14ac:dyDescent="0.3">
<c r="A2" t="str">
<f>A1</f>
<v>\"<>+-*//}{\\n</v>
</c>
<c r="B2" s="1">
<v>43835</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
xl\sharedStrings.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1">
<si>
<t>\"<>+-*//}{\\n</t>
</si>
</sst>
void Main()
{
var sb = new StringBuilder();
for (int i = 0; i < 10000000; i++)
{
sb.AppendLine("ABCDEF");
}
File.AppendAllText("test.txt",sb.ToString());
}

void Main()
{
var sb = new StringBuilder();
for (int i = 0; i < 10000000; i++)
{
sb.AppendLine(string.Join("",Guid.NewGuid().ToString().Take(6)));
}
File.WriteAllText("test.txt",sb.ToString());
}

MiniExcel
void Main()
{
var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.xlsx");
var table = new DataTable();
{
table.Columns.Add("A", typeof(string));
for (int i = 0; i < 10000000; i++)
table.Rows.Add("ABCDEF");
}
MiniExcelLibs.MiniExcel.SaveAs(path, table);
}

void Main()
{
var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.xlsx");
var table = new DataTable();
{
table.Columns.Add("A", typeof(string));
for (int i = 0; i < 10000000; i++)
table.Rows.Add(string.Join("",Guid.NewGuid().ToString().Take(6)));
}
MiniExcelLibs.MiniExcel.SaveAs(path, table);
}

Load sharedStrings.xml need load all data into memory, so tag this abandon.
sharedstring can reduce memory consumption when the user opens excel
New Logic :
- Create SQLite DB & store value into temptable
- Check if value exist then use its index