Writing to Excel worksheet but I keep receiving this error "The RPC server is unavailable"


I am trying to write to an Excel worksheet but I keep receiving this error, "System.Runtime.InteropServices.COMException: 'The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)'"

ExcelIO excel = new ExcelIO(@"C:\Users\" + Environment.UserName + @"\OneDrive\Desktop\CountiesWindSpeeds.xlsx", 1);

    public void WriteData(int i, int k, string value)
        excel.WritetoCell(i, k, value);

===========Above============ Form1.cs =====================

public class ExcelIO
    /// <summary>
    /// Getting Excel path to open it
    /// </summary>
    private string path = "";

    private _Application excel = new _Excel.Application();
    private Workbook wb;
    private Worksheet ws;

    public ExcelIO(string path, int sheet)
        this.path = path;

        wb = excel.Workbooks.Open(path);
        ws = wb.Worksheets[sheet];

    public void WritetoCell(int i, int j, string s)
        ws.Cells[i, j].Value2 = s;

===========Above============ ExcelIO.cs =====================

asked on Stack Overflow Nov 14, 2020 by Araasai

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0