View | Details | Raw Unified | Return to bug 13112
Collapse All | Expand All

(-)faq.xml (-63 / +142 lines)
Lines 1-67 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!DOCTYPE faqs PUBLIC "-//APACHE//DTD FAQ V1.1//EN" "./dtd/faq-v11.dtd">
2
<!DOCTYPE faqs PUBLIC "-//APACHE//DTD FAQ V1.1//EN" "./dtd/faq-v11.dtd">
3
3
4
<faqs title="Frequently Asked Questions">
4
<faqs title="Preguntas Más Frecuentes (FAQ)">
5
    <faq>
5
    <faq>
6
        <question>
6
        <question>
7
          What is the HSSF "eventmodel"?
7
          ¿Qué es el "eventmodel" (modelo de evento) de HSSF?
8
        </question>
8
        </question>
9
        <answer>
9
        <answer>
10
              The HSSF eventmodel package is a new API for reading XLS files more efficiently.  It does
10
              <p> El paquete "eventmodel" de HSSF es un nuevo API para la lectura más eficiente de ficheros
11
              require more knowledge on the part of the user, but reduces memory consumption by more than
11
              XML. Requiere mayor conocimiento por parte del usuario, pero reduce el consumo de memoria a
12
              tenfold.  It is based on the AWT event model in combination with SAX.  If you need read-only
12
              una décima parte. Está basado en el modelo de eventos AWT en combinación con SAX. Si necesita
13
              access to a given XLS file, this is the best way to do it.
13
              acceso de sólo-lectura a un fichero XML determinado, esta es la mejor manera de hacerlo.</p>
14
        </answer>
14
        </answer>
15
15
16
    </faq>
16
    </faq>
17
    <faq>
17
    <faq>
18
        <question>
18
        <question>
19
          Why can't read the document I created using Star Office 5.1?
19
          ¿Por qué no puedo leer el documento que creé utilizando Star Office 5.1?
20
        </question>
20
        </question>
21
        <answer>
21
        <answer>
22
              Star Office 5.1 writes some records using the older BIFF standard.  This causes some problems
22
              <p>Star Office 5.1 escribe algunos registros utilizando el viejo estándar BIFF.
23
              with POI which supports only BIFF8.
23
              Esto provoca algunos problemas con POI que sólo soporta BIFF8.</p>
24
        </answer>
24
        </answer>
25
    </faq>
25
    </faq>
26
    <faq>
26
    <faq>
27
        <question>
27
        <question>
28
            Why am I getting an exception each time I attempt to read my spreadsheet?
28
            ¿Por qué recibo una excepción cada vez que intento leer mi hoja de cálculo?
29
        </question>
29
        </question>
30
        <answer>
30
        <answer>
31
            It's possible your spreadsheet contains a feature that is not currently supported by HSSF.
31
            <p>Es posible que su hoja de cálculo contenga alguna característica que no esté
32
            For example - spreadsheets containing cells with rich text are not currently supported.
32
            soportada actualmente por HSSF. Por ejemplo - hojas de cálculo que contengan
33
            celdas con formato RTF (rich text) no están soportadas actualmente.</p>
33
        </answer>
34
        </answer>
34
    </faq>
35
    </faq>
35
    <faq>
36
    <faq>
36
        <question>
37
        <question>
37
            Does HSSF support protected spreadsheets?
38
            ¿Soporta HSSF hojas de cálculo protegidas?
38
        </question>
39
        </question>
39
        <answer>
40
        <answer>
40
            Protecting a spreadsheet encripts it.  We wont touch encription because we're not legally educated
41
            <p>Al proteger una hoja de cálculo, ésta se cifra. No tocaremos el cifrado, porque no
41
            and don't understand the full implications of trying to implement this.  If you wish to have a go
42
            tenemos el suficiente conocimiento legal y no estamos seguros de las implicaciones que
42
            at this feel free to add it as a plugin module.  We wont be hosting it here however.
43
            conllevaría el intentar implementar esto. Si desea intentarlo, es libre de hacerlo y
44
            de añadirlo como un módulo enchufable (plugin). Sin embargo, no lo guardaremos aquí.</p>
43
        </answer>
45
        </answer>
44
    </faq>
46
    </faq>
45
    <faq>
47
    <faq>
46
        <question>
48
        <question>
47
            How do you tell if a field contains a date with HSSF?
49
            ¿Cómo se sabe si un campo contiene una fecha con HSSF?
48
        </question>
50
        </question>
49
        <answer>
51
        <answer>
50
            Excel stores dates as numbers therefore the only way to determine if a cell is
52
            <p>Excel almacena las fechas como números. Así la única manera para determinar
51
            actually stored as a date is to look at the formatting. This solution from
53
            si una celda está realmente almacenada como una fecha consiste en mirar su formato.
52
            Jason Hoffman:
54
            Hay un método de ayuda (helper) en HSSFDateUtil (desde la distribución 1.7.0-dev)
53
            <p>
55
            que lo comprueba. Gracias a Jason Hoffman por proporcionar la solución.</p>
54
            Okay, here is a little code I used to determine if the cell was a number or
55
            date, and then format appropriately.  I hope it helps.  I keep meaning to
56
            submit a patch with the helper method below.... but just haven't had a
57
            chance.
58
            </p>
59
            <source>
56
            <source>
60
/////// code snippet ////////////
57
61
case HSSFCell.CELL_TYPE_NUMERIC:
58
case HSSFCell.CELL_TYPE_NUMERIC:
62
                  double d = cell.getNumericCellValue();
59
                  double d = cell.getNumericCellValue();
63
                  // test if a date!
60
                  // test if a date!
64
                  if (isCellDateFormatted(cell)) {
61
                             if (HSSFDateUtil.isCellDateFormatted(cell)) {
65
                    // format in form of M/D/YY
62
                    // format in form of M/D/YY
66
                    cal.setTime(HSSFDateUtil.getJavaDate(d));
63
                    cal.setTime(HSSFDateUtil.getJavaDate(d));
67
                    cellText =
64
                    cellText =
Lines 70-113 Link Here
70
                               cal.get(Calendar.DAY_OF_MONTH) + "/" +
67
                               cal.get(Calendar.DAY_OF_MONTH) + "/" +
71
                               cellText;
68
                               cellText;
72
                  }
69
                  }
73
/////// end code snippet ////////////
74
70
75
// HELPER METHOD BELOW TO DETERMINE IF DATE
71
            </source>
72
        </answer>
73
    </faq>
74
    <faq>
75
        <question>
76
            Estoy intentando ver un fichero XLS enviado como flujo (stream) desde un servlet y tengo
77
            complicaciones. ¿Cuál es el problema?
78
        </question>
79
        <answer>
80
            <p>
81
            El problema normalmente se manifiesta como un montón de caracteres basura
82
            en la pantalla. El problema persiste incluso aunque hayas configurado el tipo mime
83
            correcto.
84
            </p>
85
            <p>
86
            La respuesta breve es: no dependas de IE para mostrar un fichero binario. 
87
            Escribe un documento adjunto como es debido si lo envías a través de un servlet. 
88
            Toda versión de IE tiene diferentes fallos (bugs) en este sentido.
89
            </p>
90
            <p>
91
            El problema en la mayoría de las versiones de IE reside en que no utiliza el tipo mime
92
            de la respuesta HTTP para determinar el tipo de fichero; en su lugar utiliza la extensión
93
            del fichero en la petición. Así podría añadir un <strong>.xls</strong> a su cadena de petición.
94
            Por ejemplo: <em>http://yourserver.com/myServelet.xls?param1=xx</em>. Esto se consigue
95
            fácilmente a través del mapeo de URL en cualquier contenedor servlet. A veces una
96
            petición como
97
                <em>http://yourserver.com/myServelet?param1=xx&amp;dummy=file.xls</em> 
98
            también funciona.
99
            </p>
100
            <p>
101
            Para garantizar la correcta apertura del fichero en Excel desde IE, escribe
102
            tu fichero a un fichero temporal bajo su raiz web desde tu servlet. Envía entonces
103
            una respuesta http al navegador para que haga una redirección en el lado del cliente
104
            a tu fichero temporal. (Si haces una redirección en el lado del servidor utilizando
105
            RequestDispatcher, tendrás que añadir .xls a la petición como se ha mendionado más
106
            arriba)
107
            </p>
108
            <p>
109
            Date cuenta de que cuando pides un documento que se abre con un manejador externo,
110
            IE a veces realiza dos peticiones al servidor web. Así que si tu proceso generador
111
            es pesado, tiene sentido escribir a un fichero temporal, para que peticiones
112
            múltiples utilicen el fichero estático.
113
            </p>
114
            <p>
115
            Nada de esto pertenece a Excel. El mismo problema ocurre cuando intentas general
116
            cualquier fichero binario dinámicamente a un cliente IE. Por ejemplo, si generas
117
            ficheros pdf utilizando
118
                <link href="http://xml.apache.org/fop">FOP</link>,
119
                te encontrarás con los mismos problemas.
120
            </p>
121
            <!-- Gracias a Avik por la respuesta -->
122
        </answer>
123
    </faq>
124
    <faq>
125
        <question>
126
            Quiero dar formato a una celda (Data format of a cell) de una hoja excel como
127
            ###,###,###.#### o ###,###,###.0000. ¿Es posible hacer esto con POI?
128
        </question>
129
        <answer>
130
            <p>
131
                HSSF no soporta todavía formatos de datos personalizados, sin embargo,
132
                debería ser una facilidad razonablemente sencilla de añadir y aceptaremos
133
                gustosos contribuciones en este área.
134
            </p>
135
            <p>
136
                Estos son los formatos incluidos que soporta:
137
            </p>
138
            <p>
139
            <link href="http://jakarta.apache.org/poi/javadocs/javasrc/org/apache/poi/hssf/usermodel/HSSFDataFormat_java.html#HSSFDataFormat">http://jakarta.apache.org/poi/javadocs/javasrc/org/apache/poi/hssf/usermodel/HSSFDataFormat_java.html#HSSFDataFormat</link>
140
            </p>
141
        </answer>
142
    </faq>
143
    <faq>
144
        <question>
145
            ¿Cómo añado un borde alrededor de una celda unida (merged)?
146
        </question>
147
        <answer>
148
            <p>
149
            Añade celdas vacías alrededor de donde las celdas hubieran estado normalmente y
150
            configura los bordes individualmente para cada celda.
151
            Probablemente mejoraremos HSSF en el futuro para facilitar este proceso.
152
            </p>
153
        </answer>
154
    </faq>
155
    <faq>
156
        <question>
157
            Intenté escribir valores en celdas así como cambiar el nombre de la hoja Excel
158
            en mi lengua nativa, pero no pude hacerlo. :(
159
        </question>
160
        <answer>
161
            <p>
162
            Por defecto HSSF utiliza valores de celdas y nombres de hoja en unicode comprimido,
163
            asi que para soportar la localización deberías utilizar Unicode.
164
            Para hacerlo deberías configurarlo manualmente:
165
            </p>
166
            <source>
76
167
77
// method to determine if the cell is a date, versus a number...
168
                //
78
public static boolean isCellDateFormatted(HSSFCell cell) {
169
                // para el nombre de la hoja
79
    boolean bDate = false;
170
                //
171
                HSSFWorkbook wb = new HSSFWorkbook();
172
                HSSFSheet s = wb.createSheet();
173
                wb.setSheetName( 0, "SomeUnicodeName", HSSFWorkbook.ENCODING_UTF_16 );
174
175
176
                //
177
                // para el valor de la celda
178
                //
179
                HSSFRow r = s.createRow( 0 );
180
                HSSFCell c = r.createCell( (short)0 );
181
                c.setCellType( HSSFCell.CELL_TYPE_STRING );
182
                c.setEncoding( HSSFCell.ENCODING_UTF_16 );
183
                c.setCellValue( "\u0422\u0435\u0441\u0442\u043E\u0432\u0430\u044F" );
80
184
81
    double d = cell.getNumericCellValue();
82
    if ( HSSFDateUtil.isValidExcelDate(d) ) {
83
      HSSFCellStyle style = cell.getCellStyle();
84
      int i = style.getDataFormat();
85
      switch(i) {
86
        // Internal Date Formats as described on page 427 in
87
        // Microsoft Excel Dev's Kit...
88
        case 0x0e:
89
        case 0x0f:
90
        case 0x10:
91
        case 0x11:
92
        case 0x12:
93
        case 0x13:
94
        case 0x14:
95
        case 0x15:
96
        case 0x16:
97
        case 0x2d:
98
        case 0x2e:
99
        case 0x2f:
100
         bDate = true;
101
        break;
102
103
        default:
104
         bDate = false;
105
        break;
106
      }
107
    }
108
    return bDate;
109
  }
110
            </source>
185
            </source>
186
            <p>
187
            Asegúrate de que haces la llamada a setEncoding() antes de llamar a setCellValue(),
188
            si no, lo que le pases no será interpretado correctamente.
189
            </p>
111
        </answer>
190
        </answer>
112
    </faq>
191
    </faq>
113
</faqs>
192
</faqs>

Return to bug 13112