Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

erstmal der Code meiner Klasse:



public static class WriteExcel

    {

        public static bool LetsGo(int Zeilen, int Spalten, string[,] Inhalt)

        {

            try

            {

                //Variablen für die Excelanwendung, Excelworkbook und Worksheet anlegen

                Application Excel = new Application();

                Workbook ExcelWorkbook;

                Worksheet ExcelWorksheet;


                //Sogenannter First Contact (Der Excel Prozess wird initialisiert)

                Excel.Visible = true;

                Excel.ScreenUpdating = true;


                //Das Workbook (die eigentliche Exceldatei) wird angelegt

                var mycount = Excel.Workbooks.Count;

                ExcelWorkbook = (Workbook)(Excel.Workbooks.Add(System.Reflection.Missing.Value));

                ExcelWorksheet = (Worksheet)(ExcelWorkbook.ActiveSheet);


                //Inhalte aus dem String Array einfügen

                for (int i = 0; i < Zeilen; i++)

                {

                    for (int j = 0; j < Spalten; j++)

                    {

                        ExcelWorksheet.Cells[i+1, j+1] = Inhalt[i, j];

                    }

                }


                return true;


            }

            catch { return false; }

        }

    }


Diese Methode fügt den Inhalt eines Mehrdimensionalen Arrays in eine Exceltabelle ein. Nun möchte ich aber noch folgendes erreichen:

1. Die Spaltenbreite soll sich automatisch anpassen.

2. Die Umlaute sollen korrekt dargestellt werden.

Mit welchen Befehlen erreiche ich das?

Gibt es überhaupt einen Befehl der die Standardsprache auf Deutsch setzt oder so ähnlich?

Vielen Dank ;-)

Hallo nochmal,

habe es nun selbst rausgefunden:

zu 1. Durch ExcelWorkSheet.Columns.AutoFit() wird die Größe der Zellen dem Inhalt angepasst.

zu 2. Hierbei lag der Fehler nicht an Excel, sondern daran das ich die Inhalte mit einem StreamReader aus einer Textdatei gelesen habe. Beim

StreamReader muss man dann nur Encoding.Default einstellen.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.