xl-project/app/src/main/java/xl/model/XLPrintStream.java
2024-06-03 19:21:42 +02:00

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();
}
}