31 lines
782 B
Java
31 lines
782 B
Java
package xl.model;
|
|
|
|
import java.io.FileNotFoundException;
|
|
import java.io.PrintStream;
|
|
import java.util.Map.Entry;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* Specialized PrintStream for writing XL files.
|
|
*/
|
|
public class XLPrintStream extends PrintStream {
|
|
|
|
public XLPrintStream(String fileName) throws FileNotFoundException {
|
|
super(fileName);
|
|
}
|
|
|
|
public void save(Set<Entry<String, Cell>> set) {
|
|
for (Entry<String, Cell> entry : set) {
|
|
print(entry.getKey());
|
|
print('=');
|
|
Cell cell = entry.getValue();
|
|
if (cell instanceof CommentCell) {
|
|
println("#" + cell.displayValue());
|
|
} else {
|
|
println(cell.displayValue());
|
|
}
|
|
}
|
|
flush();
|
|
close();
|
|
}
|
|
}
|