convert .numbers to excel code example

Example 1: vba convert endianess

'Extremely fast VBA function to convert a LONG value from Little-Endian 
'to Big-Endian byte order representation, and vice versa:

Function ConvertEndianness&(ByVal n&)
    ConvertEndianness = (((n And -16777216) \ 16777216) And 255&) Or _
                        ((n And 16711680) \ 256&) Or ((n And 65280) * 256&) Or ((n And 127&) * 16777216)
    If (n And 128&) Then ConvertEndianness = ConvertEndianness Or &H80000000
End Function
  
'------------------------------------------------------------------------------------------------
  
MsgBox ConvertEndianness(127)			'<--displays:   2130706432
MsgBox ConvertEndianness(2130706432)	'<--displays:   127


'NB: This function converts byte order:  &h12345678 --> &h78563412
'                                        &h78563412 --> &h12345678


'Reference:
    https://en.wikipedia.org/wiki/Endianness

Example 2: convert from xls to xlsx C#

/// <summary>/// Using Microsoft.Office.Interop to convert XLS to XLSX format, to work with EPPlus library/// </summary>/// <param name="filesFolder"></param>
public static string ConvertXLS_XLSX(FileInfo file) 
{
  var app = new Microsoft.Office.Interop.Excel.Application();
  var xlsFile = file.FullName;
  var wb = app.Workbooks.Open(xlsFile);
  var xlsxFile = xlsFile + "x";
  wb.SaveAs(Filename: xlsxFile, FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
  wb.Close();
  app.Quit();
  return xlsxFile;
}

Tags:

Vb Example