0

こんにちは、ファイルを .xlsm から .xlsx に変換するための次のコード スニペットがあります。コードは C# ですが、vb で必要です。アドバイスをお願いします。

byte[] byteArray = File.ReadAllBytes("C:\\temp\\test.xlsm");
using (MemoryStream stream = new MemoryStream())
{
stream.Write(byteArray, 0, (int)byteArray.Length);
using (SpreadsheetDocument spreadsheetDoc = SpreadsheetDocument.Open(stream, true))
 // Change from template type to workbook type
{
spreadsheetDoc.ChangeDocumentType (SpreadsheetDocumentType.Workbook);
}
File.WriteAllBytes ("C:\\temp\\test.xlsx", stream.ToArray()); 
}
4

1 に答える 1

1

Have you even tried doing it by yourself? There are few good tools for that kind of conversion available online, like that one: http://www.developerfusion.com/tools/convert/csharp-to-vb/

Dim byteArray As Byte() = File.ReadAllBytes("C:\temp\test.xlsm")
Using stream As New MemoryStream()
    stream.Write(byteArray, 0, CInt(byteArray.Length))
    Using spreadsheetDoc As SpreadsheetDocument = SpreadsheetDocument.Open(stream, True)
        ' Change from template type to workbook type
        spreadsheetDoc.ChangeDocumentType(SpreadsheetDocumentType.Workbook)
    End Using
    File.WriteAllBytes("C:\temp\test.xlsx", stream.ToArray())
End Using
于 2012-11-05T06:56:08.273 に答える