This commit is contained in:
chi
2024-01-02 23:08:00 +09:00
parent 7a7b667b3d
commit e26efda0fc
33 changed files with 10068 additions and 1357 deletions

View File

@@ -51,6 +51,9 @@
<Reference Include="GrapeCity.Spreadsheet, Version=11.40.20177.0, Culture=neutral, PublicKeyToken=327c3516b1b18457" />
<Reference Include="GrapeCity.Spreadsheet.Win, Version=11.40.20177.0, Culture=neutral, PublicKeyToken=327c3516b1b18457" />
<Reference Include="GrapeCity.Win.PluginInputMan, Version=11.40.20177.0, Culture=neutral, PublicKeyToken=327c3516b1b18457, processorArchitecture=MSIL" />
<Reference Include="libxl.net">
<HintPath>..\..\DLL\libxl.net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.150.1586.0\lib\net40\Microsoft.ReportViewer.Common.dll</HintPath>
</Reference>

View File

@@ -14,6 +14,7 @@ using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace FCOMMON
{
@@ -61,6 +62,62 @@ namespace FCOMMON
#endregion
public static bool savetoexcel(DataGridView dataGridView1,string fn)
{
libxl.Book book;// = new libxl.BinBook();
book = new libxl.XmlBook();
book.setKey(FCOMMON.info.libxlCompany, FCOMMON.info.libxlKey);
var sheet = book.addSheet("Data");
var row = 0;
var col = 0;
foreach (DataGridViewColumn column in dataGridView1.Columns)
{
sheet.writeStr(row, col++, column.HeaderText);
}
for (int i = 0; i < dataGridView1.RowCount; i++)
{
row += 1;
col = 0;
foreach (DataGridViewColumn column in dataGridView1.Columns)
{
var v = dataGridView1.Rows[i].Cells[column.Index].Value;
string value = "";
if (v != null) value = v.ToString();
if (column.ValueType == typeof(int))
{
var ivalue = (int)v;
sheet.writeNum(row, col++, ivalue);
}
else if (column.ValueType == typeof(decimal))
{
var ivalue = (decimal)v;
sheet.writeNum(row, col++, (double)ivalue);
}
else if (column.ValueType == typeof(float))
{
var ivalue = (float)v;
sheet.writeNum(row, col++, ivalue);
}
else if (column.ValueType == typeof(double))
{
var ivalue = (double)v;
sheet.writeNum(row, col++, ivalue);
}
else sheet.writeStr(row, col++, value);
}
}
book.save(fn);
return true;
}
public static string Number2Hangle(long lngNumber)
{