MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

Create support sharedStrings

Open shps951023 opened this issue 4 years ago • 6 comments

image

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>\"&lt;&gt;+-*//}{\\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>\"&lt;&gt;+-*//}{\\n</t>
    </si>
</sst>

shps951023 avatar Mar 02 '21 02:03 shps951023

void Main()
{
	var sb = new StringBuilder();
	for (int i = 0; i < 10000000; i++)
	{
		sb.AppendLine("ABCDEF");
	}
	File.AppendAllText("test.txt",sb.ToString());
}

image

shps951023 avatar Mar 15 '21 06:03 shps951023

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());
}

image image

shps951023 avatar Mar 15 '21 06:03 shps951023

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);
}

image

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);
}

image

shps951023 avatar Mar 15 '21 07:03 shps951023

Load sharedStrings.xml need load all data into memory, so tag this abandon.

shps951023 avatar May 06 '21 05:05 shps951023

sharedstring can reduce memory consumption when the user opens excel

shps951023 avatar May 21 '21 01:05 shps951023

New Logic :

  1. Create SQLite DB & store value into temptable
  2. Check if value exist then use its index

shps951023 avatar Sep 29 '21 05:09 shps951023