Skip to content

Commit

Permalink
add gembox sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyLadanov committed Nov 2, 2023
1 parent 1607682 commit b43ac41
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 38 deletions.
2 changes: 0 additions & 2 deletions CPL_Converter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
<ItemGroup>
<PackageReference Include="GemBox.Spreadsheet" Version="49.0.1509" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="OfficeOpenXml.Core.ExcelPackage" Version="1.0.0" />
<PackageReference Include="Open-XML-SDK" Version="2.9.1" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>
64 changes: 28 additions & 36 deletions CplConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
using System.Threading.Tasks;
using System.IO;

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Drawing.Charts;
using OfficeOpenXml;
using OfficeOpenXml.Core.ExcelPackage;

using System.Reflection;

using GemBox.Spreadsheet;
using System.Runtime.Versioning;
using System.Windows.Forms;

namespace CPL_Converter
{
Expand Down Expand Up @@ -93,7 +90,7 @@ private String[] ParseRow(String Input)




[SupportedOSPlatform("windows")]

// Сохранение данных в MS Excel
private int OutInExcel(StreamReader inputSr)
Expand All @@ -105,22 +102,7 @@ private int OutInExcel(StreamReader inputSr)
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

ExcelFile workbook = new ExcelFile();
var worksheet = workbook.Worksheets.Add("Writing");







//// Создаём объект - экземпляр нашего приложения
//Excel.Application excelApp = new Excel.Application();
//// Создаём экземпляр рабочей книги Excel
//Excel.Workbook workBook;
//// Создаём экземпляр листа Excel
//Excel.Worksheet workSheet;
//workBook = excelApp.Workbooks.Add();
//workSheet = (Excel.Worksheet)workBook.Worksheets.get_Item(1);
var worksheet = workbook.Worksheets.Add("List1");


// Заполнение шапки таблицы
Expand All @@ -142,26 +124,36 @@ private int OutInExcel(StreamReader inputSr)
RowCount++;
}

//// Сохранение данных
//if (AutoSave)
//{
// workBook.SaveAs(FilePath);
// workBook.Close();
//}
//else
//{
// excelApp.Visible = true;
// excelApp.UserControl = true;
//}
// Сохранение данных
if (AutoSave)
{
workbook.Save(FilePath);
}
else
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();

saveFileDialog1.Filter = "Excel files (*.xlsx)|*.xlsx";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
saveFileDialog1.Title = "Путь для сохранения файла";

if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
workbook.Save(saveFileDialog1.FileName);
}
else
{

}
}

workbook.Save("Pick and place.xlsx");

// Возврат количество обработанных строк
return RowCount - 2;
}


[SupportedOSPlatform("windows")]
public int HandleCPL(String InputFileName)
{
int RowCount = 0;
Expand Down
3 changes: 3 additions & 0 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand Down Expand Up @@ -55,6 +56,7 @@ public Form1()
InitializeComponent();
}
// Обработка нажатия кнопки
[SupportedOSPlatform("windows")]
private void OpenButton_Click(object sender, EventArgs e)
{

Expand All @@ -74,6 +76,7 @@ private void OpenButton_Click(object sender, EventArgs e)
//conv.HandleCPL("D:\\WorkSpace\\FrequencyRegulator\\freqreq_control\\Pick Place\\CPL.txt");
}

[SupportedOSPlatform("windows")]
private void Form1_Load(object sender, EventArgs e)
{
// Не показывать форму при запуске
Expand Down

0 comments on commit b43ac41

Please sign in to comment.