繁体   English   中英

vb.net转换

[英]vb.net conversion

嗨,我有以下代码片段用于将文件从.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()); 
}

您甚至尝试过自己做吗? 在线提供这种转换的好工具很少,例如: 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM