MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: to XLS


Hi,
just use the underlying JExcelApi (see www.andykhan.com ).
Then
ModifySheetName["mydata.xls", {"newsheetname1", "bla"}]
will do what you want.

(* ***************************************************** *)
Off[General::spell1];
ModifySheetNames[xlsfile_String,sheetnames:{__String}]:=ModifySheetNames[xlsfile,xlsfile,sheetnames];
ModifySheetNames[xlsfile_String, newxlsfile_String,
sheetnames:{__String}] := Module[{
ljc=ToExpression["JLink`LoadJavaClass"],jn =
ToExpression["JLink`JavaNew"],wb,sheets},
Needs["JLink`"]; ToExpression["JLink`InstallJava[]"];
ljc["jxl.Workbook"];
wb = Workbook`createWorkbook[FF=jn["java.io.File", newxlsfile],
Workbook`getWorkbook[jn["java.io.File", xlsfile ]]];
sheets = wb[getSheets[]];
Do[sheets[[i]][setName[sheetnames[[i]]]], {i,
Min[Length[sheets],Length[sheetnames]]}];
 wb[write[]];
wb[close[]];
newxlsfile
];
(* ********************************************************* *)

Regards,
Rolf  Mertig
GluonVision Gmbh, Berlin


  • Prev by Date: Solving an integral in the limit.
  • Next by Date: Re: NDSolve
  • Previous by thread: Re: Solving an integral in the limit.
  • Next by thread: Re: to XLS