在我看来,您只需要一种通过编程将字节数组写入工作簿的方法。
public static void WriteToSheet(string targetBookPath, byte[] fileBytes)
{
  try {
   Â
    object x = Type.Missing;
   Â
    //Create a temp file to encapsulate Byte array
    string tmpPath = IO.Path.ChangeExtension(IO.Path.GetTempFileName(), ".xls");
    My.Computer.FileSystem.WriteAllBytes(tmpPath, fileBytes, false);
   Â
    //Start Excel Application (COM)
    Excel.Application xlApp = new Excel.Application();
   Â
    //Open target book
    Excel.Workbook targetBook = xlApp.Workbooks.Open(targetBookPath, x, x, x, x, x, x, x, x, x,
    x, x, x, x, x);
   Â
    //Open temp file with Excel Interop
    Excel.Workbook sourceBook = xlApp.Workbooks.Open(tmpPath, x, x, x, x, x, x, x, x, x,
    x, x, x, x, x);
   Â
    //Get a reference to the desired sheet
    Excel.Worksheet sourceSheet = (Excel.Worksheet)sourceBook.Worksheets(1);
   Â
    //Copy the temp sheet into WorkBook specified as "Before" parameter
    Excel.Worksheet targetBefore = (Excel.Worksheet)targetBook.Worksheets(1);
    try {
      sourceSheet.Copy(targetBefore, x);
     Â
      //Save and Close
      sourceBook.Close(false, x, x);
      targetBook.Close(true, x, x);
      xlApp.Workbooks.Close();
       Â
      xlApp.Quit();
    }
    catch (Exception ex) {
      Debug.Fail(ex.ToString);
    }
    finally {
     Â
      //Release COM objects
      // Source
      DESTROY(sourceSheet);
      DESTROY(sourceBook);
     Â
      // Target
      DESTROY(targetBefore);
      DESTROY(targetBook);
     Â
      // App
       Â
      DESTROY(xlApp);
    }
   Â
    //Kill the temp file
     Â
    My.Computer.FileSystem.DeleteFile(tmpPath);
  }
  catch (Exception ex) {
    Debug.Fail(ex.ToString);
  }
}
DESTROY方法释放COM内容,这非常重要:
public static void DESTROY(object o)
{
  try {
    System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
  }
  catch (Exception ex) {
    Debug.Fail(ex.ToString);
    ErrorLog.Write(ex.ToString);
  }
  finally {
    o = null;
  }
}
如果我理解正确,您需要做的就是:
-
-
循环字节数组
-