JustPaste.it
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
namespace Időjárás
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        string fájlnév;
        string táblanév;
        string oszlop;
        uint sor;
        string adat;
        public MainWindow()
        {
            InitializeComponent();
           
        }
        // Given a worksheet, a column name, and a row index, gets the cell at the specified column and row.
        private static Cell GetSpreadsheetCell(Worksheet worksheet, string columnName, uint rowIndex)
        {
            IEnumerable<Row> rows = worksheet.GetFirstChild<SheetData>().Elements<Row>().Where(r => r.RowIndex == rowIndex);
            if (rows.Count() == 0)
            {
                // A cell does not exist at the specified row.
                return null;
            }
            IEnumerable<Cell> cells = rows.First().Elements<Cell>().Where(c => string.Compare(c.CellReference.Value, columnName + rowIndex, true) == 0);
            if (cells.Count() == 0)
            {
                // A cell does not exist at the specified column, in the specified row.
                return null;
            }
            return cells.First();
        }
        private void Beolvas(object sender, RoutedEventArgs e)
        {
           
            fájlnév = "D:\\meteo_adatlap_v1.xlsx";
            táblanév = "Időjárás";
            using (SpreadsheetDocument táblázat = SpreadsheetDocument.Open(fájlnév, false))
            {
                IEnumerable<Sheet> sheets = táblázat.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>().Where(s => s.Name == táblanév);
                if (sheets.Count() == 0)
                {
                    // The specified worksheet does not exist.
                    return;
                }
                string relationshipId = sheets.First().Id.Value;
                WorksheetPart worksheetPart = (WorksheetPart)táblázat.WorkbookPart.GetPartById(relationshipId);
                // Éjszakai minimum
                oszlop = "B";
                sor = 4;
                Cell cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_ejszaka_min_ertek.Content = adat;
                }
                // Éjszakai maximun
                oszlop = "C";
                sor = 4;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_ejszaka_max_ertek.Content = adat;
                }
                // Éjszakai ikon
                oszlop = "D";
                sor = 4;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_ejszaka_ikon.Content = adat;
                }
                // Éjszakai szélirány
                oszlop = "E";
                sor = 4;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {                
                    adat = cell.CellValue.Text;
                    label_ejszaka_szelirany.Content = adat;
                }
                // Éjszakai szélerő
                oszlop = "F";
                sor = 4;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_ejszaka_szelero.Content = adat;
                }
                // Nappali minimum
                oszlop = "B";
                sor = 5;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_nappal_min_ertek.Content = adat;
                }
                // Nappali maximum
                oszlop = "C";
                sor = 5;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_nappal_max_ertek.Content = adat;
                }
                // Nappali ikon
                oszlop = "D";
                sor = 5;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_nappal_ikon.Content = adat;
                }
                // Nappali szélirány
                oszlop = "E";
                sor = 5;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_nappal_szelirany.Content = adat;
                }
                // Nappali szélerő
                oszlop = "F";
                sor = 5;
                cell = GetSpreadsheetCell(worksheetPart.Worksheet, oszlop, sor);
                if (cell == null)
                {
                    // The specified cell does not exist.
                    return;
                }
                else
                {
                    adat = cell.CellValue.Text;
                    label_nappal_szelero.Content = adat;
                }

            }
        }
       
    }
}