📄 xlhtml.c~
字号:
k += ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]->colspan-1; } } if (!aggressive) printf("</TR>\n"); } printf("</table></FONT><HR>"); do_cr(); } if (center_tables) { printf("</CENTER>"); do_cr(); } /* Print the author's name in itallics... */ if (author.str) { printf("<FONT SIZE=-1><I>Spreadsheet's Author: "); OutputString(&author); printf("</I></FONT><br>"); do_cr(); } /* Print when & how the file was last updated. */ printf("<FONT SIZE=-1><I>Last Updated "); if (lastUpdated) printf("%s ", lastUpdated); switch (file_version) { case EXCEL95: printf("with Excel 5.0 or 95"); break; case EXCEL97: printf("with Excel 97"); break; default: printf("with Excel ????"); break; } printf("</I></FONT><br>"); do_cr(); /* Next print Disclaimers... */ if (NoFormat) { printf("<br>* This cell's format is not supported.<br>"); do_cr(); } if ((notAccurate)&&(formula_warnings)) { printf("<br>** This cell's data may not be accurate.<br>"); do_cr(); } if (NotImplemented) { printf("<br>*** This cell's data type will be supported in the future.<br>"); do_cr(); } if (Unsupported) { printf("<br>**** This cell's type is unsupported.<br>"); do_cr(); } /* Now out exceeded capacity warnings... */ if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded || MaxStringsExceeded || MaxFontsExceeded || MaxPalExceeded || MaxXFExceeded || MaxFormatsExceeded ) printf("<FONT COLOR=\"%s\">", colorTab[0x0A]); if (MaxWorksheetsExceeded) { printf("The Maximum Number of Worksheets was exceeded, you might want to increase it.<br>"); do_cr(); } if (MaxRowExceeded) { printf("The Maximum Number of Rows was exceeded, you might want to increase it.<br>"); do_cr(); } if (MaxColExceeded) { printf("The Maximum Number of Columns was exceeded, you might want to increase it.<br>"); do_cr(); } if (MaxStringsExceeded) { printf("The Maximum Number of Strings was exceeded, you might want to increase it.<br>"); do_cr(); } if (MaxFontsExceeded) { printf("The Maximum Number of Fonts was exceeded, you might want to increase it.<br>"); do_cr(); } if (MaxPalExceeded) { printf("The Maximum Number of Color Palettes was exceeded, you might want to increase it.<br>"); do_cr(); } if (MaxXFExceeded) { printf("The Maximum Number of Extended Formats was exceeded, you might want to increase it.<br>"); do_cr(); } if (MaxFormatsExceeded) { printf("The Maximum Number of Formats was exceeded, you might want to increase it.<br>"); do_cr(); } if (MaxWorksheetsExceeded || MaxRowExceeded || MaxColExceeded || MaxStringsExceeded || MaxFontsExceeded || MaxPalExceeded || MaxXFExceeded || MaxFormatsExceeded ) printf("</FONT>"); printf(" <br>"); do_cr(); /* Output Credit */ printf("<hr><FONT SIZE=-1>Created with <a href=\"http://www.xlhtml.org/\">xlhtml %s</a></FONT><br>", VERSION); do_cr(); /* Output Tail */ output_footer();}static void OutputTableXML(void){ int i, j, k; printf( "<?xml version=\"1.0\" encoding=\"" ); switch (UnicodeStrings) { case 0: printf("iso-8859-1\" ?>\n"); /* Latin-1 */ break; case 1: printf("windows-1252\"?>\n"); /* Microsoft */ break; default: printf("utf-8\"?>\n"); /* Unicode */ break; } SetupExtraction(); printf( "<excel_workbook>\n" ); printf( "\t<sheets>\n" ); /* Here's where we dump the Html Page out */ for (i=first_sheet; i<=last_sheet; i++) /* For each worksheet */ { trim_sheet_edges(i); update_default_font(i); 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; printf( "\t\t<sheet>\n" ); printf( "\t\t\t<page>%d</page>\n", i ); /* Print its name */ if (next_ws_title > 0) { if (ws_array[i]->ws_title.str) { printf("\t\t\t<pagetitle>"); OutputString(&ws_array[i]->ws_title); printf("</pagetitle>\n"); } else printf("\t\t\t<pagetitle>(Unknown Page)</pagetitle>\n"); } printf( "\t\t\t<firstrow>%ld</firstrow>\n", ws_array[i]->first_row ); printf( "\t\t\t<lastrow>%ld</lastrow>\n", ws_array[i]->biggest_row ); printf( "\t\t\t<firstcol>%d</firstcol>\n", ws_array[i]->first_col ); printf( "\t\t\t<lastcol>%d</lastcol>\n", ws_array[i]->biggest_col ); printf( "\t\t\t<rows>\n" ); for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++) { update_default_alignment(i, j); printf("\t\t\t\t<row>\n"); for (k=ws_array[i]->first_col; k<=ws_array[i]->biggest_col; k++) { printf("\t\t\t\t\t<cell row=\"%d\" col=\"%d\">", j, k ); output_cell(ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k], 1); /* This stuff happens for each cell... */ printf("</cell>\n" ); if (ws_array[i]->c_array[(j*ws_array[i]->max_cols)+k]) { 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; } } printf("</row>\n"); } printf( "\t\t\t</rows>\n" ); printf("\t\t</sheet>\n"); } printf( "\t</sheets>\n" ); /* Print the author's name in itallics... */ if (author.str) { printf("\t<author>"); OutputString(&author); printf("</author>\n"); } /* Print when & how the file was last updated. */ if (lastUpdated) printf("\t<lastwrite>%s</lastwrite>", lastUpdated); printf( "\t<excelversion>" ); switch (file_version) { case EXCEL95: printf("using Excel 5.0 or 95"); break; case EXCEL97: printf("using Excel 97/2000"); break; default: printf("using Excel ????"); break; } printf("</excelversion>\n"); /* Next print Disclaimers... */ if (NoFormat) printf("\t<noformat>%d</noformat>\n", NoFormat ); if ((notAccurate)&&(formula_warnings)) printf("\t<accuracy>%d</accuracy>\n", notAccurate ); if (NotImplemented) printf("\t<notimplemented>%d</notimplemented>\n", NotImplemented ); if (Unsupported) printf("\t<unsupported>%d</unsupported>\n", Unsupported ); /* Now out exceeded capacity warnings... */ if (MaxWorksheetsExceeded) printf("\t<MaxWorksheetsExceeded>The Maximum Number of Worksheets were exceeded, you might want to increase it.</MaxWorksheetsExceeded>\n "); if (MaxRowExceeded) printf("\t<MaxRowExceeded>The Maximum Number of Rows were exceeded, you might want to increase it.</MaxRowExceeded>\n "); if (MaxColExceeded) printf("\t<MaxColExceeded>The Maximum Number of Columns were exceeded, you might want to increase it.</MaxColExceeded>\n"); if (MaxStringsExceeded) printf("\t<MaxStringsExceeded>The Maximum Number of Strings were exceeded, you might want to increase it.</MaxStringsExceeded>\n"); if (MaxFontsExceeded) printf("\t<MaxFontsExceeded>The Maximum Number of Fonts were exceeded, you might want to increase it.</MaxFontsExceeded>\n"); if (MaxPalExceeded) printf("\t<MaxPalExceeded>The Maximum Number of Color Palettes were exceeded, you might want to increase it.</MaxPalExceeded>\n"); if (MaxXFExceeded) printf("\t<MaxXFExceeded>The Maximum Number of Extended Formats were exceeded, you might want to increase it.</MaxXFExceeded>\n"); if (MaxFormatsExceeded) printf("\t<MaxFormatsExceeded>The Maximum Number of Formats were exceeded, you might want to increase it.</MaxFormatsExceeded>\n"); /* Output Credit */ printf("\t<tool>Created with xlhtml %s</tool>\n", VERSION); printf("\t<toollink>http://www.xlhtml.org/</toollink>\n"); printf( "</excel_workbook>\n" );}static void SetupExtraction(void){ if (Xtract) { /* Revise the page settings... *//* printf("-%d %d %d %d %d<br>\n", xp, xr1, xr2, xc1, xc2); */ if ((xp >= first_sheet)&&(xp <= last_sheet)&&(xp <= sheet_count)) { first_sheet = xp; last_sheet = xp; if (xr1 < 0) { xr1 = (S16)ws_array[xp]->first_row; xr2 = (S16)ws_array[xp]->biggest_row; } else if ((xr1 >= ws_array[xp]->first_row)&&(xr1 <= ws_array[xp]->biggest_row) &&(xr2 >= ws_array[xp]->first_row)&&(xr2 <= ws_array[xp]->biggest_row)) { ws_array[xp]->first_row = xr1; ws_array[xp]->biggest_row = xr2; if (xc1 < 0) { xc1 = ws_array[xp]->first_col; xc2 = ws_array[xp]->biggest_col; } else if((xc1 >= ws_array[xp]->first_col)&&(xc1 <= ws_array[xp]->biggest_col) &&(xc2 >= ws_array[xp]->first_col)&&(xc2 <= ws_array[xp]->biggest_col)) { ws_array[xp]->first_col = xc1; ws_array[xp]->biggest_col = xc2; } else { if (Ascii) fprintf(stderr, "Error - Col not in range during extraction" " (%d or %d not in [%d..%d])\n", xc1, xc2, ws_array[xp]->first_col, ws_array[xp]->biggest_col); else { printf("Error - Col not in range during extraction.\n"); output_footer(); } return; } } else { if (Ascii) fprintf(stderr, "Error - Row not in range during extraction" " (%d or %d not in [%ld..%ld])\n", xr1, xr2, ws_array[xp]->first_row, ws_array[xp]->biggest_row); else { printf("Error - Row not in range during extraction."); output_footer(); } return; } } else { if (Ascii) fprintf(stderr, "Error - Page not in range during extraction."); else { printf("Error - Page not in range during extraction."); output_footer(); } return; } }}static void output_header(void){ /* Ouput Header */ if (NoHeaders) return; if (!aggressive) { printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML Transitional//EN\""); do_cr(); printf("\"http://www.w3.org/TR/REC-html40/loose.dtd\">"); do_cr(); } printf("<HTML><HEAD>"); do_cr(); printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); if ((UnicodeStrings <= 1)&&CodePage&&(CodePage != 1252)) printf("windows-%d\">", CodePage); else { switch (UnicodeStrings) { case 0: printf("iso-8859-1\">"); /* Latin-1 */ break; case 1: printf("windows-1252\">"); /* Microsoft */ break; default: printf("utf-8\">"); /* Unicode */ break; } } do_cr(); if (!aggressive) { printf("<meta name=\"GENERATOR\" content=\"xlhtml\">"); do_cr(); } printf("<TITLE>"); if (title) printf("%s", title); else printf("%s", filename); printf("</TITLE>"); do_cr(); printf("</HEAD>"); do_cr(); do_cr(); printf("<BODY TEXT=\"#%s\" BGCOLOR=\"#%s\"", default_text_color, default_background_color); if (default_image) printf("BACKGROUND=\"%s\"", default_image); printf("><br>"); do_cr();}static void output_footer(void){ if (NoHeaders) return; printf("</BODY></HTML>"); do_cr(); fflush(stdout);}/*!******************************************************************* \param count the absolute count in the record* \param last the size of the record* \param bufidx the index into the working buffer* \param buflast the expected length of the working buffer********************************************************************/static void main_line_processor(U16 opcode, U16 version, U32 count, U16 last, U8 data){ U16 cont_opcode = 0; /* If first pass, reset stuff. */ if (count == 0) { if (opcode != 0x3C) /* continue command *//* { printf("\n* * * * * * CONTINUE * * * * * * * * *\n\n"); } else */ { /* Normal path... */ last_opcode = opcode; bufidx = 0; buflast = 0; cont_str_array = 0; memset(working_buffer, 0, WBUFF_SIZE); } } if (opcode == 0x3C) { opcode = last_opcode; cont_opcode = 1; } /* Abort processing if too big. Next opcode will reset everything. */ if (bufidx >= WBUFF_SIZE) { /*printf("OC:%02X C:%04X I:%04X BL:%04X cch:%04X gr:%04X\n", opcode, count, bufidx, buflast, cch, grbit); */ /*abort(); */ return; } /* no chart processing for now. */ if (version == 0x0010) return; switch (opcode) { case 0x09: /* BOF */ working_buffer[bufidx++] = data; if (bufidx == last) { if (file_version == 0) { /* File version info can be gathered here... * 4 = Excel version 4 * 1280 = Excel version 5 * 0500 = Excel 95 * 1536 = Excel 97 */ if (version == 8) file_version = getShort(&working_buffer[0]); else file_version = version; if (file_version == EXCEL95) { use_colors = 0; HARD_MAX_ROWS = HARD_MAX_ROWS_95; }/* printf("Biff:%X\n", file_version); */ } sheet_count++; if (sheet_count >= (int)max_worksheets) add_more_worksheet_ptrs(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -