@@ -191,6 +191,9 @@ internal static extern TypesC.CellNameToCoordinatesResult CellNameToCoordinates(
191191 [ DllImport ( LibraryName , CallingConvention = CallingConvention . Cdecl ) ]
192192 internal static extern IntPtr Close ( long fileIdx ) ;
193193
194+ [ DllImport ( LibraryName , CallingConvention = CallingConvention . Cdecl ) ]
195+ internal static extern IntPtr CopySheet ( long fileIdx , int from , int to ) ;
196+
194197 [ DllImport ( LibraryName , CallingConvention = CallingConvention . Cdecl ) ]
195198 internal static extern TypesC . IntErrorResult ColumnNameToNumber (
196199 [ MarshalAs ( UnmanagedType . LPUTF8Str ) ] string name
@@ -366,12 +369,12 @@ public static object CsValToCInterface(object value)
366369 value switch
367370 {
368371 int _ => new Interface { Type = 1 , Integer = ( int ) value } ,
369- string _ => new Interface { Type = 2 , String = ( string ) value } ,
370- double _ => new Interface { Type = 3 , Float = ( double ) value } ,
371- float _ => new Interface { Type = 3 , Float = ( float ) value } ,
372- long _ => new Interface { Type = 3 , Float = ( long ) value } ,
373- short _ => new Interface { Type = 3 , Float = ( short ) value } ,
374- bool _ => new Interface { Type = 4 , Boolean = ( bool ) value } ,
372+ string _ => new Interface { Type = 3 , String = ( string ) value } ,
373+ double _ => new Interface { Type = 4 , Float = ( double ) value } ,
374+ float _ => new Interface { Type = 4 , Float = ( float ) value } ,
375+ long _ => new Interface { Type = 4 , Float = ( long ) value } ,
376+ short _ => new Interface { Type = 4 , Float = ( short ) value } ,
377+ bool _ => new Interface { Type = 5 , Boolean = ( bool ) value } ,
375378 _ => new Interface { Type = 0 } ,
376379 } ,
377380 new TypesC . Interface ( )
@@ -2356,11 +2359,26 @@ public string Close()
23562359 return Marshal . PtrToStringUTF8 ( Lib . Close ( FileIdx ) ) ;
23572360 }
23582361
2362+ /// <summary>
2363+ /// Duplicate a worksheet by gave source and target worksheet index.
2364+ /// Note that currently doesn't support duplicate workbooks that contain
2365+ /// tables, charts or pictures.
2366+ /// </summary>
2367+ /// <param name="buffer">The contents buffer of the file</param>
2368+ /// <exception cref="RuntimeError">Return None if no error occurred,
2369+ /// otherwise raise a RuntimeError with the message.</exception>
2370+ public void CopySheet ( int from , int to )
2371+ {
2372+ string err = Marshal . PtrToStringUTF8 ( Lib . CopySheet ( FileIdx , from , to ) ) ;
2373+ if ( ! string . IsNullOrEmpty ( err ) )
2374+ throw new RuntimeError ( err ) ;
2375+ }
2376+
23592377 /// <summary>
23602378 /// Get formatted value from cell by given worksheet name and cell
23612379 /// reference in spreadsheet. The return value is converted to the
2362- /// ' string' data type. If the cell format can be applied to the value
2363- /// of a cell, the applied value will be returned, otherwise the
2380+ /// <c> string</c> data type. If the cell format can be applied to the
2381+ /// value of a cell, the applied value will be returned, otherwise the
23642382 /// original value will be returned. All cells' values will be the same
23652383 /// in a merged range.
23662384 /// </summary>
0 commit comments