Some more code modularization.
This commit is contained in:
137
xlhtml/ascii.c
137
xlhtml/ascii.c
@ -26,78 +26,85 @@
|
||||
|
||||
|
||||
|
||||
void OutputPartialTableAscii(void)
|
||||
void
|
||||
OutputPartialTableAscii (void)
|
||||
{
|
||||
int i, j, k;
|
||||
int i, j, k;
|
||||
|
||||
SetupExtraction();
|
||||
SetupExtraction ();
|
||||
|
||||
/* Here's where we dump the Html Page out */
|
||||
for (i=first_sheet; i<=last_sheet; i++) /* For each worksheet */
|
||||
/* Here's where we dump the Html Page out */
|
||||
for (i = first_sheet; i <= last_sheet; i++) /* For each worksheet */
|
||||
{
|
||||
if (ws_array[i] == 0)
|
||||
continue;
|
||||
if ((ws_array[i]->biggest_row == -1)
|
||||
|| (ws_array[i]->biggest_col == -1))
|
||||
continue;
|
||||
if (ws_array[i]->c_array == 0)
|
||||
continue;
|
||||
|
||||
/* Now dump the table */
|
||||
for (j = ws_array[i]->first_row; j <= ws_array[i]->biggest_row; j++)
|
||||
{
|
||||
if (ws_array[i] == 0)
|
||||
continue;
|
||||
if ((ws_array[i]->biggest_row == -1)||(ws_array[i]->biggest_col == -1))
|
||||
continue;
|
||||
if (ws_array[i]->c_array == 0)
|
||||
continue;
|
||||
for (k = ws_array[i]->first_col; k <= ws_array[i]->biggest_col; k++)
|
||||
{
|
||||
int safe, numeric = 0;
|
||||
cell *c = ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]; /* This stuff happens for each cell... */
|
||||
|
||||
/* Now dump the table */
|
||||
for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++)
|
||||
if (c)
|
||||
{
|
||||
for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++)
|
||||
{
|
||||
int safe, numeric=0;
|
||||
cell *c = ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]; /* This stuff happens for each cell... */
|
||||
numeric = IsCellNumeric (c);
|
||||
if (!numeric && Csv)
|
||||
printf ("\"");
|
||||
safe = IsCellSafe (c);
|
||||
|
||||
if (c)
|
||||
{
|
||||
numeric = IsCellNumeric(c);
|
||||
if (!numeric && Csv)
|
||||
printf("\"");
|
||||
safe = IsCellSafe(c);
|
||||
|
||||
if (c->ustr.str)
|
||||
{
|
||||
if (safe)
|
||||
output_formatted_data(&(c->ustr), xf_array[c->xfmt]->fmt_idx, numeric, IsCellFormula(c));
|
||||
else
|
||||
OutputString(&(c->ustr));
|
||||
}
|
||||
else if (!Csv)
|
||||
printf(" "); /* Empty cell... */
|
||||
}
|
||||
else
|
||||
{ /* Empty cell... */
|
||||
if (!Csv)
|
||||
printf(" ");
|
||||
else
|
||||
printf("\"");
|
||||
}
|
||||
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]) /* Honor Column spanning ? */
|
||||
{
|
||||
if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan != 0)
|
||||
k += ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan-1;
|
||||
}
|
||||
if (!numeric && Csv)
|
||||
printf("\"");
|
||||
|
||||
if (Csv && (k < ws_array[i]->biggest_col))
|
||||
{ /* big cheat here: quoting everything! */
|
||||
putchar(','); /* Csv Cell Separator */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (( !Csv )&&( k != ws_array[i]->biggest_col ))
|
||||
putchar('\t'); /* Ascii Cell Separator */
|
||||
}
|
||||
}
|
||||
if (Csv)
|
||||
printf("\r\n");
|
||||
else
|
||||
putchar(0x0A); /* Row Separator */
|
||||
if (c->ustr.str)
|
||||
{
|
||||
if (safe)
|
||||
output_formatted_data (&(c->ustr),
|
||||
xf_array[c->xfmt]->fmt_idx,
|
||||
numeric, IsCellFormula (c));
|
||||
else
|
||||
OutputString (&(c->ustr));
|
||||
}
|
||||
else if (!Csv)
|
||||
printf (" "); /* Empty cell... */
|
||||
}
|
||||
if (!Csv)
|
||||
printf("\n\n"); /* End of Table 2 LF-CR */
|
||||
else
|
||||
{ /* Empty cell... */
|
||||
if (!Csv)
|
||||
printf (" ");
|
||||
else
|
||||
printf ("\"");
|
||||
}
|
||||
if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]) /* Honor Column spanning ? */
|
||||
{
|
||||
if (ws_array[i]->c_array[(j * ws_array[i]->max_cols) + k]->
|
||||
colspan != 0)
|
||||
k +=
|
||||
ws_array[i]->c_array[(j * ws_array[i]->max_cols) +
|
||||
k]->colspan - 1;
|
||||
}
|
||||
if (!numeric && Csv)
|
||||
printf ("\"");
|
||||
|
||||
if (Csv && (k < ws_array[i]->biggest_col))
|
||||
{ /* big cheat here: quoting everything! */
|
||||
putchar (','); /* Csv Cell Separator */
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((!Csv) && (k != ws_array[i]->biggest_col))
|
||||
putchar ('\t'); /* Ascii Cell Separator */
|
||||
}
|
||||
}
|
||||
if (Csv)
|
||||
printf ("\r\n");
|
||||
else
|
||||
putchar (0x0A); /* Row Separator */
|
||||
}
|
||||
if (!Csv)
|
||||
printf ("\n\n"); /* End of Table 2 LF-CR */
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user